Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
IamPhilG committed May 26, 2022
1 parent 6e9b732 commit b9a92c6
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 0 deletions.
14 changes: 14 additions & 0 deletions FuncGoToEnd.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function GoToEnd($timer)
{
# Restore location
Pop-Location

$timer.Stop()
$runTime = "$($timer.Elapsed)"

[Log]::new("Script Runtime full: $runtime").Out()
[Log]::new("The End.").Out()

# Stops log
[Log]::new((Stop-Transcript)).Out()
}
11 changes: 11 additions & 0 deletions GetUserObjectSID.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[CmdLetBinding()]
Param(
[Parameter(Mandatory=$true, valueFromPipeLine = $true)]
[String]$SamAccountName,

[Parameter(Mandatory=$false)]
[String]$Domain = (Get-ADDomain).NetBiosName
)
$ObjectId = [String]($Domain + "\" + $SamAccountName)
$account = New-Object System.Security.Principal.NTAccount $ObjectId
$account.Translate([System.Security.Principal.SecurityIdentifier]).Value
6 changes: 6 additions & 0 deletions SetDateAndTimeInformation.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#region Time / Date Info
$DateRef = [datetime]::Now
$Timer = [system.diagnostics.stopwatch]::StartNew()
$dateSimple = $DateRef.toString("yyyyMMdd")
$dateStamped = $DateRef.ToString("yyyyMMdd.HHmmss")
#endregion#>
11 changes: 11 additions & 0 deletions SetEnd.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Restore location
Pop-Location

$timer.Stop()
$runTime = "$($timer.Elapsed)"

[Log]::new("Script Runtime full: $runtime").Out()
[Log]::new("The End.").Out()

# Stops log
[Log]::new((Stop-Transcript -ErrorAction SilentlyContinue)).Out()
28 changes: 28 additions & 0 deletions SetFiles.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# SetFilesCLass.ps1 is mandatory
[CmdLetBinding()]
Param(
[Parameter(Mandatory=$true, valueFromPipeLine = $true)]
[String]$_scriptLocation
)

#region files and paths
# Determine script location for PowerShell
if ( $_ScriptLocation -eq $null -or $_ScriptLocation -eq "" )
{
$_ScriptLocation = "."
}
[Files]::base = $_scriptlocation

# Set Files retention (7 is by default)
[Files]::FilesToKeep = 3

# Determine current location
Push-Location
$_savWorkDir = Get-Location

# Force WorkDir to be the same as Script location
if ($_savWorkDir.Path -ne [Files]::Base)
{
Set-Location ([Files]::Base)
}
#endregion#>
17 changes: 17 additions & 0 deletions SetPaths.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SetFilesCLass.ps1 is mandatory
[CmdLetBinding()]
Param(
[Parameter(Mandatory=$true, valueFromPipeLine = $true)]
[String]$_ScriptFullName
)

#region paths
$Paths = @{
Logs = [Files]::new("Logs")
Results = [Files]::new("Results").SetName($dateSimple + "." + 'Result.csv').Finalize()
Script = [Files]::new().SetName($_ScriptFullName).Finalize()
Bck = [Files]::new("Backups").SetName($dateSimple + "." + 'Backup.csv').Finalize()
Roll = [Files]::new("RollBacks").SetName($dateSimple + "." + 'RollBack.ps1').Finalize()
}
$null = $Paths.Logs.SetName($dateStamped + "." + ( [System.IO.Path]::GetFileNameWithoutExtension($_ScriptFullName) ).ToLower() + '.log').Finalize()
#endregion#>
30 changes: 30 additions & 0 deletions SetStart.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#region Prep

$rawSpace="`n`n`n`n`n`n"

$_paramEC = @{
path = ".\"
Encoding = "UTF8"
Delimiter = ';'
NoTypeInformation = $true
Force = $true
}

# To prevent any running transcript
try {
Stop-Transcript -ErrorAction SilentlyContinue | out-null
}
catch [System.InvalidOperationException]
{
$Error.Clear()
}

clear-host

# Create a margin so you can see what is on the screen
Write-host $rawSpace

[Log]::new((Start-Transcript -Path ($Paths.Logs.FullPath))).Out()
[Log]::Release()

#endregion#>

0 comments on commit b9a92c6

Please sign in to comment.