Skip to content

Instantly share code, notes, and snippets.

View macfarmw's full-sized avatar

Matthew MacFarland macfarmw

  • Lexis Nexis Risk
View GitHub Profile
@macfarmw
macfarmw / gist:67e318423aeb15184c623eca22b56b59
Last active July 23, 2017 03:47
Cool PowerShell trick I don't understand.
$days = 'MON,TUE,WED'
$dayCodes = $days.Split(',') | .{
process {
switch($_){
'SUN' {1}
'MON' {2}
'TUE' {4}
'WED' {8}
'THU' {16}
@macfarmw
macfarmw / Invoke-CommandOutput.ps1
Last active July 23, 2017 03:47
Output from Invoke-Command ScriptBlock
...
$results = Invoke-Command -ComputerName localhost -Authentication Credssp -Credential $credential -ScriptBlock {
$exitCode = 0
$output = @()
try {
$output += "Copying files..."
Copy-Item "$Using:workspace\AMERICAS\Netlogon\*.*" \\USDC4\NETLOGON -Force -ErrorAction Stop
Copy-Item "$Using:workspace\APAC\Netlogon\*.*" \\SGDC2\NETLOGON -Force -ErrorAction Stop
Copy-Item "$Using:workspace\EMEA\Netlogon\*.*" \\UKDC3\NETLOGON -Force -ErrorAction Stop