ps remoting how:
http://searchwindowsserver.techtarget.com/feature/How-to-enable-PowerShell-remoting
Get-Module -ListAvailable
mstsc /v:main-aux.something.local (to nie jest ps tylko rd)
Enter-PSSession -ComputerName main-aux.something.local
Get-ADGroup -Filter * -SearchBase "ou=something,dc=polish,dc=local" |ft -AutoSize -Property name
Use the Add-ADGroupMember cmdlet, and remember to use the SAM account name on the computer:
Start-Process calc -Verb runas
Start-Process notepad -verb runas
Get-ADuser -Filter 'name -like "adam*"' -Properties *
Get-ADComputer -Filter 'name -like "PAAPC-849"' -Properties *
$comp = Get-ADComputer -Filter 'name -like "PAAPC-849"' -Properties *
$comp = Get-ADComputer -Filter 'name -like "PAAPC-849"'
Add-ADGroupMember "64bitOS" -Members $comp
Get-ADComputer -Identity paapc-1105
repadmin /replicate main-aux learning-staff "DC=something,DC=local"
dsquery ou
$PSVersionTable
remove-adcomputer -Identity paapc-858
*****************************************************
Get-Module -ListAvailable
Import-Module ActiveDirectory
get-adcomputer -Identity PAAPC-857
(result)
DistinguishedName : CN=PAAPC-857,OU=Office South,OU=Computers,OU=something,DC=something,DC=local
DNSHostName : PAAPC-857.something.local
Enabled : True
Name : PAAPC-857
ObjectCldynamic ass : computer
ObjectGUID : 20b3b662-87ed-4e4f-b10d-e6e9078fb87f
SamAccountName : PAAPC-857$
SID : S-1-5-21-285955686-4169195788-511705716-5726
UserPrincipalName :
Get-ADComputer -Identity paapc-858
(result)
DistinguishedName : CN=PAAPC-858,OU=Office Main,OU=Computers,OU=polish,DC=polish,DC=local
DNSHostName : PAAPC-858.something.local
Enabled : True
Name : PAAPC-858
ObjectClass : computer
ObjectGUID : e1539f4d-f29e-4f95-b81c-800e9a3757f6
SamAccountName : PAAPC-858$
SID : S-1-5-21-285955686-4169195788-511705716-5716
UserPrincipalName :
Remove-ADComputer -Identity paapc-858
repadmin /replicate main-aux learning-staff "DC=something,DC=local"
get-adcomputer -Identity adminpo-8p140oa [name of newly reimaged machine]
[result]
DistinguishedName : CN=ADMINPO-8P140OA,CN=Computers,DC=polish,DC=local
DNSHostName : ADMINPO-8P140OA.polish.local
Enabled : True
Name : ADMINPO-8P140OA
ObjectClass : computer
ObjectGUID : efc0699d-5528-4204-bca1-bfee7e08bf47
SamAccountName : ADMINPO-8P140OA$
SID : S-1-5-21-285955686-4169195788-511705716-6185
UserPrincipalName :
[now I am checkin where it should be moved to, to what container]
[learning-staff.polish.local]: PS C:\Users\john\Documents> get-adcomputer -Identity solina
DistinguishedName : CN=SOLINA,OU=Office Main,OU=Computers,OU=something,DC=something,DC=local
DNSHostName : Solina.something.local
Enabled : True
Name : SOLINA
ObjectClass : computer
ObjectGUID : 2bba91a1-826e-4c45-8c33-61c6ac1632ed
SamAccountName : SOLINA$
SID : S-1-5-21-285955686-4169195788-511705716-4637
UserPrincipalName :
Move-ADObject -Identity "CN=ADMINPO-8P140OA,CN=Computers,DC=something,DC=local" -TargetPath "OU=Office Main,OU=Computers,OU=something,DC=something,DC=local"
Rename-ADObject "CN=ADMINPO-8P140OA,OU=Office Main,OU=Computers,OU=something,DC=something,DC=local" -NewName PAAPC-858
[remember to rename computer also, not only AD object]
Get-ADGroup -Filter * -SearchBase "ou=polish,dc=polish,dc=local" |ft -AutoSize -Property name
$comp = Get-ADComputer -Identity paapc-858
Add-ADGroupMember -Identity "64bitOS" -Members $comp
Add-ADGroupMember -Identity "Office2010v2" -Members $comp
Add-ADGroupMember -Identity "Office2010v2" -Members $comp
Add-ADGroupMember -Identity "windows7" -Members $comp
Add-ADGroupMember -Identity "UltraVNC" -Members $comp
******************************************************************************************
Get-PSDrive
Set-Location alias:
something soft dist groups: 64bitOS,Office2010v2,windows7,UltraVNC
copy-item
Get-ADOrganizationalUnit -Filter {Name -like '*'} | FT Name, DistinguishedName -A (listing OU in AD)
auditing and installing updates:
http://blogs.technet.com/b/heyscriptingguy/archive/2011/08/13/use-powershell-to-audit-and-install-windows-patches.aspx
get-adgroupmember windows7 | ft -AutoSize -Property name (displays group members by property name “name”)
get-aduser -Filter 'Name -like "Jan Kowalski"'
Get-ADUser -Filter * -SearchBase "OU=DisabledUserAccounts,OU=Office,OU=Managed Users,DC=progressive,DC=local" | Disable-ADAccount
**************************script moving users to ou based on csv*********************
# Specify target OU.
$TargetOU = "OU=DisabledUserAccounts,OU=Office,OU=Managed Users,DC=something,DC=local"
# Read user sAMAccountNames from csv file (field labeled "SamAccountName").
Import-Csv -Path C:\Users\Administrator\Desktop\disablUsers.csv | ForEach-Object {
# Retrieve DN of User.
$UserDN = (Get-ADUser -Identity $_.SamAccountName).distinguishedName
# Move user to target OU.
Move-ADObject -Identity $UserDN -TargetPath $TargetOU
}
***********************************ps1***********************************************************
Get-DistributionGroupMember -Identity dyskoteka | ft name, primarysmtpaddress
add-MailboxPermission -Identity "John Doe" -User "NT Authority\SELF" -Accessright Fullaccess
Remove-DistributionGroupMember -Identity "junior-board" -Member "John Kovalski"
*******************************
Create csv file with the following columns: Name, PrimarySmtpAddress
Import-CSV FileName.csv | ForEach {Add-DistributionGroupMember -Identity "DG Name" -Member $_.Name}
*************************************************************************
Dynamic distribution group members:
$FTE = Get-DynamicDistributionGroup "Full Time Employees"
Get-Recipient -RecipientPreviewFilter $FTE.RecipientFilter
$FTE = Get-DynamicDistributionGroup "something"
Get-Recipient -RecipientPreviewFilter $FTE.RecipientFilter
(getting the list of e-mail addresses)
$dl = Get-DynamicDistributionGroup “something”
$allr = Get-Recipient -RecipientPreviewFilter $dl.RecipientFilter -OrganizationalUnit $dl.RecipientContainer –ResultSize Unlimited
$allr | Select-Object Name,PrimarySmtpAddress | Export-Csv -Path “paaOfficeStaff.csv” –NoTypeInformation