View ps_Errors.ps1
function Reset-Errors {
$psISE.Options.ErrorForegroundColor = '#FFFF0000'
$Global:ErrorView = 'NormalView'
#generate an error
function Show-Error {
Get-Item c:\doesnotexist.txt
View Splat.ps1
$paramHash = @{
ServiceName = "BITS"
ComputerName = "Localhost"
Outvariable = "results"
Get-Service @paramHash
View DataCapture.ps1
$hostname = $env:COMPUTERNAME
hostname | Out-File C:\$hostname.txt -Append
ipconfig /all | Out-File C:\$hostname.txt -Append
Get-NetAdapter | Out-File C:\$hostname.txt -Append
Get-VMSwitch | Out-File C:\$hostname.txt -Append
Get-Cluster | Out-File C:\$hostname.txt -Append
Get-ClusterGroup | Out-File C:\$hostname.txt -Append
Get-ClusterResource | Out-File C:\$hostname.txt -Append
Get-ClusterNetwork | Out-File C:\$hostname.txt -Append
Get-Disk | Out-File C:\$hostname.txt -Append
View enable_HV_PS.ps1
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Management-PowerShell -All
View cmd_commands.ps1
$command = 'C:\somepath\someexe.exe somearg'
iex $command
#full working example
$command = 'cmd.exe /c "C:\Program Files (x86)\Bginfo\BgInfo.exe" "C:\Program Files (x86)\Bginfo\config_2016.bgi\" /silent /accepteula /timer:0'
iex "& $command"
View Shares.ps1
View secureString.ps1
$password = Read-Host "Enter your password"
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
View FileRemove.ps1
$path = 'C:\path\Test.txt'
if (Test-Path $path) {
Write-Host "$path detected, removing file before starting..."
try {
Remove-Item -Path $path -Force -Confirm:$false -ErrorAction Stop
catch {
Write-Host "Unable to remove $path"
View computerName.ps1
if ($txtComputerName.Text -notmatch '(?i)(?=.{5,15}$)^(([a-z\d]|[a-z\d][a-z\d\-]*[a-z\d])\.)*([a-z\d]|[a-z\d][a-z\d\-]*[a-z\d])$') {
$allGood = $false
[System.Windows.Forms.MessageBox]::Show("The computer name you specified was not valid.", "Computer Name not valid")
View suffixes.ps1
#set suffixes
$suffixes = ",,"
$command = @"
cmd.exe /C "wmic nicconfig call SetDNSSuffixSearchOrder ($domain,$suffixes)"
Invoke-Expression -Command:$command -ErrorAction SilentlyContinue
#reverse suffixes change
#Append Primary and connection specific DNS suffixes
#Append parent suffixes of the primary DNS suffix