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 Get-XKCD{ | |
| [cmdletbinding(DefaultParameterSetName=’Specific’)] | |
| Param ( | |
| [Parameter(ParameterSetName=’Specific’,ValueFromPipeline=$True,Position=0)][int[]]$Num, | |
| [Parameter(ParameterSetName=’Random’)][switch]$Random, | |
| [Parameter(ParameterSetName=’Random’)][int]$Min = 1, | |
| [Parameter(ParameterSetName=’Random’)] | |
| [int]$Max = ((Invoke-WebRequest "http://xkcd.com/info.0.json").Content | ConvertFrom-Json).num, | |
| [Parameter(ParameterSetName=’Newest’)][int]$Newest, | |
| [switch]$Download |
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
| #Adapted from here http://mikefrobbins.com/2012/08/30/finding-aliases-for-powershell-cmdlet-parameters/ | |
| (get-command *).parameters.values | select name,aliases | sort aliases -unique | sort name | |
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
| $requestBody = Get-Content $req -raw | |
| $requestBody = $requestBody.Replace('&',"`n") | |
| $requestBody = ConvertFrom-StringData -StringData $requestBody | |
| $Response = (Import-CSV "D:\home\site\wwwroot\Glossary\Glossary.csv") | Where-Object {$_.Term -like "$($requestBody.text)*"} | |
| if(!$Response){Out-File -Encoding Ascii -FilePath $res -inputObject "Sorry, there is no match in the Glossary for *$($requestBody.text)*."} | |
| $Response | ForEach-Object{ | |
| Out-File -Encoding Ascii -FilePath $res -inputObject "*$($_.Term):* $($_.Description)" -Append |
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
| <# | |
| .Synopsis | |
| Glossary Module | |
| .DESCRIPTION | |
| A Powershell Module that includes a function for searching a CSV file which is a Glossary of terms and presents the results in a variety of formats. | |
| .EXAMPLE | |
| Search-Glossary MyTerm | |
| .EXAMPLE | |
| Search-Glossary MyTerm -PassThru | Export-CSV MyTerms.csv | |
| #> |
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
| Get-WmiObject Win32_logicaldisk | Export-Clixml "$env:computername-LogicalDisks.xml" | |
| (Get-Service | select name,displayname,status) | Export-Clixml "$env:computername-Services.xml" | |
| (Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object {$_.IPEnabled -eq "True"}) | Export-Clixml "$env:computername-Network.xml" |
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
| Param( | |
| $SEPLatestVersion = "12.1.7" | |
| ) | |
| Describe 'Symantec Endpoint Protection checks' { | |
| Context 'SEP service checks' { | |
| $SEPServices = @('SepMasterService','SmcService') |
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
| [CmdletBinding()] | |
| Param( | |
| [CmdletBinding(SupportsShouldProcess = $true)] | |
| $Inputfile | |
| ) | |
| Import-CSV Credentials.csv | ForEach-Object { | |
| $Body = "Dear $($_.GivenName), | |
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
| [CmdletBinding()] | |
| Param( | |
| $limit = (Get-Date).AddDays(-7), | |
| $path = "C:\Example\Path" | |
| ) | |
| # Delete files older than the $limit. | |
| $FilesToDelete = (Get-ChildItem -Path $path -Exclude Logs | Where-Object { $_.LastWriteTime -lt $limit }) | Select Path | |
| # If files are deleted create a log detailing this |
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
| [CmdletBinding()] | |
| param ( | |
| $Paths = (Import-CSV "Paths.csv") | |
| ) | |
| $i = 0 | |
| $Total = 0 | |
| $Paths | ForEach-Object { | |
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
| Describe 'My process checks' { | |
| Context 'Checking essential Windows processes are running' { | |
| It 'winlogon.exe is running' { | |
| get-process -Name 'winlogon' | Should be $true | |
| } | |
| } |