Last active
December 27, 2015 11:29
-
-
Save mwjcomputing/7318897 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function New-PoshSecTemplate { | |
| [CmdletBinding()] | |
| param( | |
| ## Baseline Parmerter Set | |
| [Parameter(ParameterSetName='Baseline')] | |
| [switch]$Baseline, | |
| [Parameter(ParameterSetName='Baseline')] | |
| [string]$BaselinePath | |
| ) | |
| begin{ | |
| ## Script Variables | |
| $local:BaselinePrefix = "Processes" | |
| $local:BaselineFileErrorMessage = "The path specified does not exist. The baseline was not saved." | |
| } | |
| process{ | |
| $local:object = Get-CimInstance -ClassName Win32_Process | |
| } | |
| end{ | |
| if($Baseline) { | |
| $local:Filename = Get-DateISO8601 -Prefix $local:BaselinePrefix -Suffix ".xml" | |
| if ($BaselinePath) { | |
| if (Test-Path -Path $BaselinePath) { | |
| $local:FilePath = Join-Path -Path $BaselinePath -ChildPath $local:Filename | |
| } else { | |
| Write-Warning -Message $local:BaselineFileErrorMessage | |
| break | |
| } | |
| } elseif ($global:PoshSecBaselinePath) { | |
| if (Test-Path -Path $global:PoshSecBaselinePath) { | |
| $local:FilePath = Join-Path -Path $global:PoshSecBaselinePath -ChildPath $local:Filename | |
| } else { | |
| Write-Warning -Message $local:BaselineFileErrorMessage | |
| break | |
| } | |
| } else { | |
| $local:FilePath = Join-Path -Path $env:USERPROFILE\Documents -ChildPath $local:Filename | |
| } | |
| $local:object | Export-Clixml $local:FilePath | |
| } else { | |
| Write-Output $local:object | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment