Force User to Change Password a day before their password expires

[code language=”powershell” title=”Powershell code snippet”] Get-ADUser -Filter ‘(enabled -eq $true) -and ((passwordneverexpires -eq $false) -and (pwdlastset -ne 0 ))’ -properties MsDS-UserPasswordExpiryTimeComputed | sort-object name | select-object Name,sAmAccountName,@{Name="PasswordExpiry";Expression={(([datetime]::fromfiletime(($_."MsDS-UserPasswordExpiryTimeComputed"))))}} | % { if(($_.PasswordExpiry -ne $null) -and ((($_.PasswordExpiry – (Get-Date)).Days) -le 1)) { Set-ADUser $_.Name -ChangePasswordAtLogon $true } } [/code] Schedule task on AD [code language=”powershell” title=”Complete Powershell …

Copy AD Members/Users from one Group to another using Powershell

The following script will Add the users from Group_A to Group_B only when the user doesn’t exist on Group_B and Group_C [code language=”powershell” gutter=”true” highlight=”4,7″ light=”true” title=”PowerShell Code”] Import-Module ActiveDirectory $Group_BUsers = Get-ADGroup Group_B -properties members | Select-Object members | % { $_.Members} $Group_CUsers = Get-ADGroup Group_C -properties members | Select-Object members | % { …

Display ADGroups of a User (Memberof)

From the GUI (dsa.msc) Trough PowerShell The line below returns a array of strings, in this case the distinguished names of the ADGroups. Get-ADUser Siva -Properties Memberof | %{$_.memberof} CN=iLO-Admins,CN=Users,DC=MULPURU,DC=LOCAL CN=SQL-Admins,CN=Users,DC=MULPURU,DC=LOCAL CN=SCVMM-Admins,CN=Users,DC=MULPURU,DC=LOCAL CN=WDM-Admins,CN=Users,DC=MULPURU,DC=LOCAL CN=SCCM-Support,CN=Users,DC=MULPURU,DC=LOCAL CN=CTXPVS-Admins,CN=Users,DC=MULPURU,DC=LOCAL CN=XenDesktop-Admins,CN=Users,DC=MULPURU,DC=LOCAL CN=APPV-Admins,CN=Users,DC=MULPURU,DC=LOCAL Pipe the string array with for-each loop to Get-ADGroup command-let and select only the names Get-ADUser Siva -Properties …

Populate ADGrp with Filterd Users from Other ADGrps

########################################################################### # # NAME:Populate_ADGrp_with_filterd_users_from_Other_ADGrps.ps1 # # AUTHOR: SivaMulpuru # # COMMENT: Handles existing members of a ADGrp more effectively # # VERSION HISTORY: # 1.0 7/19/2011 – Initial release # ########################################################################### if(!((get-module -name ActiveDirectory).Name -eq “ActiveDirectory”)) { Import-Module ActiveDirectory } if(!$?) { “Could not load the AD PowerShell Module.” “Exiting ….” exit } #String Array …

WordPress Appliance - Powered by TurnKey Linux