Last active
August 29, 2015 14:24
-
-
Save yradunchev/d75efb02b53a2320190a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #copy membership: | |
| Get-ADUser -Identity (read-host 'Copy form User') -Properties memberof | Select-Object -ExpandProperty memberof | Add-ADGroupMember -Members (read-host 'Copy to User') -PassThru | Select-Object -Property SamAccountName | |
| #find who is logged on | |
| gwmi -computername fancylaptop -class win32_computersystem -property username | select UserName | |
| #list printers | |
| Get-WMIObject Win32_Printer -ComputerName fancylaptop | |
| #get rsop: | |
| Get-GPResultantSetOfPolicy -user general\username -computer fancylaptop -ReportType html -Path C:\temp\rsop.html | |
| #list members of AD group incuding members of nested groups, export to csv: | |
| Get-ADGroupMember -identity “Dev_Team_South” -Recursive | select name,samaccountname | Export-csv -path groupmembers.csv -NoTypeInformation | |
| #add list of users to AD group: | |
| Import-Csv "C:\temp\users.csv" | ForEach { Add-ADGroupMember -identity $_.Group -member $_.UserName } | |
| #copy members of one AD group to another | |
| Get-ADGroupMember "group1" | Foreach-Object {Add-ADGroupMember -Identity "group2" -Members $_} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment