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
# Sample data | |
$systemData = @{ | |
'System1' = @( | |
'Person1' | |
'Person2' | |
'Person3' | |
) | |
'System2' = @( | |
'Person1' | |
'Person3' |
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
$Events = Get-WinEvent -LogName Security -MaxEvents 10 | |
foreach ($Event in $Events) { | |
$MessageLineArray = $Event.Message -split "`r`n" | |
if ($MessageLineArray.Count -ge 1) { | |
$MessageLineArray[0] | |
} | |
} |
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
$Params = @{ | |
Query = "SELECT [CERTIFIED & UNASSESSED SKILL] FROM master where [CERTIFIED & UNASSESSED SKILL] LIKE '%Citrix%'" | |
ServerInstance = 'dc2012\sqlexpress' | |
Database = 'final' | |
} | |
Invoke-Sqlcmd @Params | ForEach-Object { $_['CERTIFIED & UNASSESSED SKILL'] -split ',' } | Where-Object { $_ -like '*Citrix*' } |
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
$filePath = "C:\Temp" | |
$selectPropertyList = @( | |
@{n='FileName';e={$_.Name.ToUpper()}} | |
@{n='Length (MB)';e= {($_.Length/1MB).ToString('N2')}} | |
) | |
$files = Get-ChildItem -Path $filePath -File -Recurse -Force | | |
Select-Object -Property $selectPropertyList | | |
Sort-Object -Property 'Length (MB)' -Descending | Out-GridView |
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
$filePath = "C:\Temp" | |
$selectPropertyList = @( | |
@{n='FileName';e={$_.Name.ToUpper()}} | |
@{n='Length (MB)';e= {[System.Decimal]::Round($_.Length/1MB, 2)}} | |
) | |
$files = Get-ChildItem -Path $filePath -File -Recurse -Force | | |
Select-Object -Property $selectPropertyList | | |
Sort-Object -Property 'Length (MB)' -Descending | Out-GridView |
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
$Interests = @( | |
'Automation' | |
'AWS' | |
'Amazon Web Services' | |
'Cloud Computing' | |
'Chef' | |
'Puppet' | |
'Docker' | |
'Containers' | |
'Red Hat Enterprise Linux' |
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
# Script Disk Space | |
$users = “xxxxxxxx” # List of users to email your report to (separate by comma) | |
$fromemail = “xxxxxxxxx” | |
$server = “xxxxxxx” #enter your own SMTP server DNS name / IP address here | |
$list = "C:\Powershell Script\list.txt" #This accepts the argument you add to your scheduled task for the list of servers. i.e. list.txt | |
$computers = Get-Content -Path $list #grab the names of the servers/computers to check from the list.txt file. | |
$mydate = Get-Date | |
# Set free disk space threshold below in percent (default at 10%) | |
[decimal]$thresholdspace = 10 |
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
if ($Event[0].Message -match 'sequence number (?<SequenceNumber>\d+)') | |
{ | |
'Sequence number found: {0}' -f $Matches.SequenceNumber | |
} |
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
# Option 1: Access the capture group (\d+) by number. | |
if ($Event[0].Message -match 'sequence number (\d+)') | |
{ | |
$Number = $Matches[1] | |
} | |
# Option 2: Access the number using the named capture group "Number" | |
if ($Event[0].Message -match 'sequence number (?<Number>\d+)') | |
{ | |
$Number = $Matches.Number |