# $Users = gc c:\temp\users.txt | get-ADUser foreach ($User in $Users) $UserUPN = $User.UserPrincipalname $UserUPNwithOutDomain = ([regex]::matches($UserUPN, "([^@]+)")).value[0] Set-ADUser $User -userprincipalname "$UserUPNwithOutDomain@microsoft.com" }
These are just random notes and programs that may have incomplete descriptions. Any scripts or programs use at your risk
Showing posts with label get-aduser. Show all posts
Showing posts with label get-aduser. Show all posts
Tuesday, October 18, 2016
Powershell: Change UPN on list of users
I needed a script to bulk change a list of users to a new UPN i came up with this.
Tuesday, May 21, 2013
Powershell: Gather all user objects and report lastlogon and lastlogontimestamp to CSV file
Purpose:
Connects to active directory and pulls a list of all user objects and create a report of lastlogon and lastlogontimestamp values
Note: This is something i did around midnight so i need to do further testing on this script to ensure the data is correct and the lastlogon value will only be from the DC the script is running against
#Tony Unger #Scans all user accounts and reports lastlogon and lastlogontimestamp attr. Import-Module ActiveDirectory $AllUsers = get-aduser -Filter * -SearchBase "DC=microsoft,DC=Com" -Property SamAccountName,Lastlogon,LastlogonTimeStamp | Select Name,UserPrincipalname,SamAccountName,@{Name='Last Logon Timestamp';Expression={[System.DateTime]::FromFileTime($_.LastLogonTimestamp).ToString('g')}},@{Name='Last Logon';Expression={[System.DateTime]::FromFileTime($_.LastLogon).ToString('g')}} $AllUsers | Export-Csv -Path "c:\Audit_UsersLastLogon.csv" -NoTypeInformation
Subscribe to:
Posts (Atom)
Powershell: Microsoft Graph to add new roles to application registration
PowerShell Script Bulk add new roles to application registration in azure. Update $roles with ,Us...
-
Here is an excel document I created that will ping a list of nodes in column A and give results in column B. There are much better tools th...
-
#reads event logs for filter and exports to $Date = ( Get-Date ).AddMinutes(-30) $LogName = 'Security' $ProviderName = ...
-
Using Google Chrome or MS Edge: Disable Javascript post page load. 1. Open console in dev tools 2. press ctrl - alt - p 3. In the run dial...