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
    
  
  
    
  | Invoke-RestMethod http://ipinfo.io/json | 
  
    
      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-ADDomaincontroller -Filter * | % {$DC = $_.name ; Get-ADuser someguy -properties * -Server $_.name | select @{n="LastLogon";e={[datetime]::FromFileTime($_.lastlogon)}},@{n="DC";e={$DC}} } | sort -Property lastlogon -Descending | 
  
    
      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
    
  
  
    
  | # copy a database from one sql server to another (or the same one) | |
| az account set --subscription "my-subscription" | |
| az sql db copy --dest-name "database-copy-name" --dest-resource-group "database-resource-group" --dest-server "target-sql-server" --name "current-database-name" --resource-group "database-resource-group" --server "current-sql-server" | 
  
    
      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
    
  
  
    
  | # a short openssl command to convert a PEM split key and cert | |
| # into a PFX/pkcs12 file | |
| openssl pkcs12 -inkey myprivatekey.key -in mycertificate.crt -export -out mypkcs12bundle.pfx | 
  
    
      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-content "$env:systemroot\system32\drivers\etc\services" | Sort-Object | Get-Unique).Where({$_ -ne ""})) | out-file "$env:systemroot\system32\drivers\etc\services.dedupe" | |
| Copy-Item -Path "$env:systemroot\system32\drivers\etc\services" -Destination "$env:systemroot\system32\drivers\etc\services.$(get-date -Format yyyyMMdd)_backup" | |
| move-item -Path "$env:systemroot\system32\drivers\etc\services.dedupe" -Destination "$env:systemroot\system32\drivers\etc\services" -Force | 
  
    
      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
    
  
  
    
  | $nodes = @("node1","node2","node3") | |
| foreach ($node in $nodes) | |
| { | |
| invoke-command -computername $node -scriptblock { | |
| $hostsOriginal = @" | |
| # Copyright (c) 1993-2009 Microsoft Corp. | |
| # | |
| # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. | |
| # | 
  
    
      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
    
  
  
    
  | $configuredGroup = "MyServer - Local Administrators" | |
| $targetServers = "server1","server2","server3" | |
| $membersOfConfiguredGroup = get-adgroupmember $configuredGroup | |
| foreach ($server in $targetServers) | |
| { | |
| add-adgroupmember -Members $membersOfConfiguredGroup -Identity (get-adgroup "$server - Local Administrators") | |
| } | 
  
    
      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
    
  
  
    
  | # hackish event log dump | |
| wevtutil el | Foreach-Object {wevtutil cl "$_"} | 
  
    
      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
    
  
  
    
  | az account set --subscription mySubScriptionGuid | |
| zip debug-php.zip index.php | |
| az webapp deployment source config-zip --resource-group appservice-rg --name appservice-name --slot appservice-slot --src ./debug-php.zip | 
  
    
      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
    
  
  
    
  | openssl req -x509 -newkey rsa:2048 -keyout myserver.foo.com-key.pem -out myserver.foo.com-cert.pem -sha256 -days 1095 -subj "/C=US/ST=ST/L=MyCity/O=MyCompany/OU=Information Technology/CN=myserver.foo.com" -config my_cert_ext -extensions 'my server exts' -nodes | |
| openssl pkcs12 -export -in myserver.foo.com-cert.pem -inkey myserver.foo.com-key.pem -out myserver.foo.com-pfx.pfx |