| Loop | Return | Continue | Break |
|---|---|---|---|
| Normal Expectation | Exit Scope | Next Item | Exit Loop |
| .foreach{} | Next Item | Break Scopes / Next Item of Parent Loop | Break Scopes / Exit Parent Loop |
| foreach ($y in $x) | Exit Scope | Next Item | Exit Loop |
| for ($i;$i -lt 5;$i++) | Exit Scope | Next Item | Exit Loop |
| Foreach-Object -InputObject @() | Next Item | Break Scopes / Next Item of Parent Loop | Break Scopes / Exit Parent Loop |
| Switch | Exit Scope | Next Item | Exit Switch |
| While |
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
| #requires -module PowerAlto, ImportExcel | |
| $ErrorActionPreference = 'Stop' | |
| if (-not $MacVendorCache) { | |
| Write-Warning 'MacVendorCache not found, downloading from maclookup.app. This is common on the first run.' | |
| $SCRIPT:MacVendorCache = @{} | |
| foreach ($entry in $(ConvertFrom-Csv (Invoke-RestMethod 'https://maclookup.app/downloads/csv-database/get-db'))) { | |
| $MacVendorCache[$entry.'Mac Prefix'] = $entry.'Vendor 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
| @(echo off) > $null | |
| set null( New-Module -ScriptBlock { function goto { }; function :{ } } )#= | |
| : # This file is both a .cmd script and a powershell script. if you save it as | |
| : # sample.cmd and run it it from cmd.exe it will run the same as if you | |
| : # saved it as sample.ps1 and run it. | |
| : # well, in this case, I added some echos on the cmd side... | |
| goto :CMDSTART |
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(SupportsShouldProcess=$True)] | |
| param( | |
| # What .tar.gz file should be extracted? Must exist. | |
| [Parameter(Mandatory=$True)] | |
| [string]$FileToExtract, | |
| # What folder should the files be extracted into? Does not need to exist | |
| [Parameter(Mandatory=$True)] | |
| [string]$TargetFolder, |
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
| # Tail Sitecore log files, even when using rolling log files | |
| # ========================================================== | |
| # 1) Copy this file into your App_Data folder or set the logFolder parameter to point to the Sitecore logs folder. | |
| # 2) Run it in Powershell | |
| # 3) View the log messages as they appear (even if the worker process recycles) | |
| param ( | |
| [string]$logFolder = ".\\logs\\", | |
| [string]$filter = "log.*", | |
| [int]$tailAmount = 20 | |
| ) |
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
| $currentWU = Get-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "UseWUServer" | select -ExpandProperty UseWUServer | |
| Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "UseWUServer" -Value 0 | |
| Restart-Service wuauserv | |
| Get-WindowsCapability -Name RSAT* -Online | Remove-WindowsCapability –Online | |
| Add-WindowsCapability –online –Name “Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0” | |
| Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "UseWUServer" -Value $currentWU | |
| Restart-Service wuauserv |
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
| $packages = @( | |
| #dev tools | |
| "jetbrains-rider", | |
| "dotcover", | |
| "dotpeek", | |
| "dotmemory", | |
| "dottrace", | |
| "vscode", | |
| "gitkraken", |
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
| const crypto = require('crypto'); | |
| const request = require('request'); | |
| const bufSecret = Buffer('OUTGOING-WEBHOOK-SECRET', "base64"); | |
| const flowWebhook = 'MICROSOFT-FLOW-URL'; | |
| module.exports = function (context, req) { | |
| var auth = req.headers['authorization']; | |
| // HMAC security validation |
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 ConvertTo-ChocoPackage { | |
| <# | |
| .SYNOPSIS | |
| Convert a PowerShell module into a chocolatey package. | |
| .DESCRIPTION | |
| Convert a PowerShell module into a chocolatey package. | |
| .EXAMPLE | |
| Find-Module pester | ConvertTo-ChocoPackage | |
| Find the module pester on a PS repository and convert the module to a chocolatey package. |
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
| <# | |
| # ┌ ┐ | |
| # sources | |
| # └ ┘ | |
| https://gist.github.com/cloudRoutine/87c17655405cd8b1eac7 | |
| https://gist.github.com/furzeface (not sure where profile.ps1 URL disappeared to) | |
| #> | |
| # If this script is throwing an error near a Unicode symbol try resaving the file as UTF-8 with BOM | |
| $psmodules = ";~\Documents\WindowsPowerShell\Modules" |
NewerOlder