Windows/PowerShell Notes
Load context
foreach($server in (get-content 'C:\Downloads\pilot_dev_servers.txt')){Get-ADComputer -Identity $server | select -ExpandProperty DistinguishedName}
Missing powershell commands
e.g. get-content missing, search https://docs.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Management/Get-Content?view=powershell-7
its in Import-Module Microsoft.PowerShell.Management
Get info on a machine by id
#Powershell > import-module activedirectory Get-ADComputer -Identity "abcd" | select -ExpandProperty DistinguishedName
Err
> Get-ADComputer -Identity "abcd" | select -ExpandProperty DistinguishedName Get-ADComputer : The term 'Get-ADComputer' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1
Reason missing admin module get-module -listavailable
- Fix
http://blog.technotesdesk.com/active-directory-module-and-cmdlet-missing-upon-patching
RSAT tool https://www.microsoft.com/en-us/download/details.aspx?id=45520
After install still got import error
> import-module activedirectory WARNING: Error initializing default drive: 'Unable to find a default server with Active Directory Web Services running.'.