This script will help you to delete folders on remote hosts. The folder names in the example are like $NtUninstallKB* and are located on the remote system admin$ shares. The remote computers are listed on the file C:\temp\BOOK1.txt Script :
Change the user UPN
Disable and move inactive computer accounts
Export users to a CSV file
Export users to a CSV file Script : Script (with Microsoft Active Directory module loaded : import-module activedirectory) : Get-ADUser -filter * -ResultSetSize $null -Properties SamAccountName,displayname,description ` | select-Object SamAccountName,displayname,description ` | Export-Csv “c:\folder\export.csv” Script (with Quest Active Directory module)
Retrieve the domain controller hostnames in a forest
With this script, you will be able to retrieve the domain controller hostnames in a forest. $myForest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() $myforest.Sites | % { $_.Servers } | Select Name, Domain References MSDN Forest Class Properties Name Description ApplicationPartitions Gets a collection
Enumerate all cluster resources and their possible owners
This script will help you to enumerate all cluster resources and their possible owners on the cluster name “ClusterVirtualNode00”. Get-Cluster -Name ClusterVirtualNode00 | Get-ClusterResource | Get-ClusterOwnerNode References Get-ClusterOwnerNode Syntax Get-ClusterOwnerNode [-InputObject ] [-Cluster ] [-Group ] [-Resource ] [-ResourceType ]
Get all cluster resources and their dependencies
This script uses the cmdlet Get-Cluster to get all cluster resources and their dependencies Command : Get-Cluster -Name ClusterName | Get-ClusterResource | Get-ClusterResourceDependency References Get-Cluster Syntax Get-Cluster [-Domain ] [] Domain Get-Cluster [[-Name] ] [] Name Detailed Description This cmdlet
Find all locked out user account
Find all locked out user account This cmdlet lists all locked out user account in the current Active Directory domain Script : Search-ADAccount -LockedOut | select DistinguishedName References Search-ADAccount Syntax Search-ADAccount -AccountDisabled [-AuthType { | }] [-ComputersOnly ] [-Credential ]
Execute a cmdlet on a remote system with Invoke-Command
Enumerate all domains in a forest
You will be able to enumerate all domains in a forest : the script lists all domain names (FQDN) in an Active Directory forest Script : @(([System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()).Domains |select name ) References System.DirectoryServices.ActiveDirectory Namespace The System.DirectoryServices.ActiveDirectory namespace provides a high level abstraction object