AD Users
Description | Command |
---|---|
Display Users in a specific OU | Get-ADUser -ResultSetSize 3000 -SearchBase "ou=Team1,ou=Users,ou=MyBusiness,DC=Contoso,DC=local" -Filter * | Select Name |
Update Users in a specific OU | Get-ADUser -ResultSetSize 3000 -SearchBase "ou=Team1,ou=Users,ou=MyBusiness,DC=Contoso,DC=local" -Filter * | Set-ADUser -PasswordNeverExpires $false |
Get Users with a profile path beginning… | Get-ADUser -Filter {ProfilePath -like "\\fileserver1\Profiles$\*"} -Properties profilepath |
Get all ACTIVE users | Get-ADUser -Filter 'enabled -eq $true' | select name | export-csv c:\temp\users.csv |
Add users in an OU to a Security Group | get-aduser -searchbase "ou=Team1,ou=Users,ou=MyBusiness,DC=Contoso,DC=local" -filter * | Add-ADPrincipalGroupMembership -MemberOf "Security Group Name" |
Copy group membership to a different group | $Sgroupmem = Get-ADGroupmember -Identity $SourceGroupAdd-ADGroupmember -Identity $TargetGroup -Member $Sgroupmem |
Set the email field for users in a specific OU | Get-ADUser -Filter * -SearchBase 'OU=Staff,OU=Users,DC=Domain,DC=local' -server "Servername" | ForEach-Object { Set-ADUser -EmailAddress ($_.givenname + '.' + $_.surName + '@domain.com') -Identity $_ -server "Servername"} |
Password last set… | get-aduser -filter * -properties passwordlastset, passwordneverexpires |ft Name, passwordlastset, Passwordneverexpires |
Users in a group, with a password older than a week! | get-adgroupmember "Office 365 Password Sync" | get-aduser -properties passwordlastset, passwordneverexpires | where {$_.passwordlastset -lt ((get-date).AddDays(-7))} | ft Name, passwordlastset, Passwordneverexpires |
Virtual Machines
Description | Command |
---|---|
Live Migrate a VM | Get-VM "VMtobeMoved" -ComputerName "NameofCurrentHyperVHost" | Move-VM -DestinationHost "NameofDestinationHost" -IncludeStorage -DestinationStoragePath "D:\VMtobeMoved" |
Posts (Tagged: Powershell)
- User prompts in PowerShell
- Setting Modern or Basic Auth
- Send-Mail
- Checking if a variable has been submitted to a function
- Module Directory in PowerShell
- Credentials in Powershell
- Debugging and Breakpoints in Powershell
- Simple popups in PowerShell
- Remoting in PowerShell
- Returning just the value in PowerShell
- Syntax in PowerShell
- Alias in PowerShell
- Help in PowerShell
- Environmental Variables in PowerShell
- Objects in Powershell
- Filtering on Multiple Fields
- Scheduled Powershell Script
- WSUS Commands
- Windows 10 1809 Optional Features (inc RSAT)
- Distribution Group Memberships for Office 365 in PowerShell