-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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#> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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#> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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#> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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#> |