Basics
less than a minute
Script header
<#
.FileName
PortQuery-AD-Client2DC.ps1
.Synopsis
Uses PortQry.exe and a predefined port list to test network
ports between a pair of domain controllers.
.Example
Run the script
.Author
Neil Grinnall, DT, GE Renewable Energy
.Created
April 2020
#>
Get the Powershell version
$Psversiontable
Get-Host | Select-Object Version
Compress a file
$path = "D:\ADS\ADSBackupGPO\backup"
$children = Get-ChildItem -Path $path | select-object name
foreach ($child in $children) {
$childname = $child.name
Compress-Archive -Path $path\$childname -DestinationPath "$path\$childname.zip"
Remove-Item -Recurse $path\$childname -Force
}
Generate a password
$Lcase = (97..122 | ForEach-Object {[char]$_} | Get-Random -Count 3)
$Ucase = (65..90 | ForEach-Object {[char]$_} | Get-Random -Count 3)
$Number = (49..57 | ForEach-Object {[char]$_} | Get-Random -Count 3)
$Password = -join ("$Lcase", "$Ucase", "$Number")
$password = $Password.replace(' ','')
$Password
Last modified July 21, 2024: update (e2ae86c)