Skip to main content

Powershell

Alias

To get the Alias of a command:    Get-Alias - Definition "yourCommandHere"    Reverse:    G...

Count Users in AD Group

(Get-ADGroup MFA_Users-Properties*).Member.Count    From <https://help.clouduss.com/mfa-knowled...

Crazy Mouse

Add-Type -AssemblyName System.Windows.Forms;Add-Type -AssemblyName System.Drawing;for($d=0;;$d+=....

DSQUERY // ADComputer

Get password info  ITBR Data Gathering Commands  Onboarding Commands          Dsquery comp...

Enable Script Execution

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned    From <https://technet.microsoft.com/librar...

Get Group Members

$GRP = "Wisys"    Get-ADGroupMember -identity $GRP | select name | Export-csv -path C:\Accent\O...

Get Hash of a File

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/get-filehash?view...

Import Users from CSV to Group Name

Import-csv "filename.csv" | %{ add-adgroupmember "groupname" -member $_.samaccountname }    Fro...

Inactive Computers

$DaysInactive = 365  $time = (Get-Date).Adddays(-($DaysInactive))      Print on Screen:    ...

Modules

Find-Module -Name AzureAd | Install-Module 

Move 1 VHD at a time

TAGS: HyperV Move VM              $vmName = "ACS-00-VSRV45"  $hostName = "CM-05-SAN01"  ...

Move VM

Tags: HyperV VM VHD Compress        This will move all parts of the VM to a central location....

Network

Lookup MAC in ARP with Powershell with exact address - Get-NetNeighbor | ? { $_.LinkLayerAddress ...

Parameters and Variables

To get Powershell variables available hit CTRL + Enter        Then to get paramet...

Powershell AD

import-module grouppolicy  get-command –module grouppolicy      These commands are needed to ...

Powershell AD User Commands

Get-ADUser -SearchBase “OU=Lincoln,OU=RHSC,dc=rhsc,dc=local” -Filter * -Properties DisplayName, E...

Powershell create PC object

dsadd computer "cn=RHSC-33-LT03, OU=Mobile,OU=Workstation,OU=Belle Plaine,OU=RHSC,DC=RHSC,DC=loca...

Powershell Get Volume Cluster Size

Powershell Get Volume Cluster Size  $wql = "SELECT Label, Blocksize, Name FROM Win32_Volume WHER...

Powershell Services

Get a listing of all services that are set to 'Automatic' startup that is currently 'Stopped'  G...

Powershell to purge checkpoints

Get-VMSnapshot -ComputerName "MyHyperVHost" -VMName "VMWithLingeringBackupCheckpoint"    From <...

PowerShell: Get, Modify, Create, and Remove Registry Keys or Parameters

https://woshub.com/how-to-access-and-manage-windows-registry-with-powershell/#:~:text=You%20can%2...

PST Mailbox Import Export

Exchange 2016:  Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn  foreach ($Mailbox...

Public Folders

Remove Public Folders      Get-PublicFolder -Server <server containing the public folder datab...

Remove lingering snapshots

Get-VMSnapshot -ComputerName "MyHyperVHost" -VMName "VMWithLingeringBackupCheckpoint"        ...

Remove old files from folder

Get-ChildItem –Path  “C:\inetpub\logs\LogFiles” –Recurse -file | Where-Object CreationTime –lt (G...

Remove spaces from files and folders

$path = "Set path per location"  Get-ChildItem $path -File -Recurse | Where-Object { $_.Name.Con...

Safe Sender

dsadd computer "cn=RHSC-33-LT03, OU=Mobile,OU=Workstation,OU=Belle Plaine,OU=RHSC,DC=RHSC,DC=loca...

Search all DHCP servers in a domain for a hostname

Get-DhcpServerInDC <#| ?{ $_.DnsName -notmatch "rhsc-01-vsrv04"} #> | % {  $_.DnsName    $Serve...

Search Users

Active Users:    Get-ADUser -Filter "Enabled -eq 'True'" | Select-Object sAMAccountName, name |...

Searching

To search a folder and subfolders for a wildcard word and aggregate to a  single folder. (THIS MO...

Sync AD with AAD

Start-ADSyncSyncCycle -PolicyType Delta 

Increase function count to Max

$maximumfunctioncount = '32768'

Create & Manage DNS Zones and Records with PowerShell

Create & Manage DNS Zones and Records with PowerShell https://woshub.com/create-manage-dns-zones...

Configure Network Settings on Windows with PowerShell: IP Address, DNS, Default Gateway, Static Routes

https://woshub.com/powershell-configure-windows-networking/ Configure Network Settings on Window...