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
View basics.ps1
#get the domain
$domain = $env:USERDNSDOMAIN
#Get Operating System Info
try {
$sOS = Get-WmiObject -class Win32_OperatingSystem
$Script:OS = $sOS.Caption
catch {
$Script:OS = "ERROR - Could not determine the OS version."
View progressBar.ps1
Write-Progress -Activity "Test" -PercentComplete 25
Write-Progress -Activity "Test" -PercentComplete 50
Write-Progress -Activity "Test" -PercentComplete 75
Write-Progress -Activity "Test" -PercentComplete 100
View Date_Manip.ps1
$certInfo = ls Cert:\LocalMachine\My | where { $_.Subject -eq $subject }
$expireDate = $certInfo.NotAfter
[int]$daysRemaining = New-TimeSpan -End $expireDate | Select-Object -ExpandProperty Days
$date = Get-Date
$1weekOut = $date.AddDays(7)