I had a request recently to provide an inactive user report for the past 60 days. Basically, find out which accounts have not logged in for the past 60 days so action can be taken against them. The request was for a multi domain forest which queries every domain controller and gets the latest lastlogon…
Tag: powershell
Convert a Dynamic IP to Static
Working on a project where on some servers the DHCP assigned addresses needs to be converted to static. Since there is always more than one…I needed to script it. Here is a quick way to do it via PowerShell. Hope this helps!
Force Replication of all Domain Controllers on all Sites
If you want to replicate all Domain Controllers, then you have to start replication on each of them separately. This may take a while. To save time there is an easier way to force replication on all Domain Controllers of all Active Directory Sites. Log on to one of your Domain Controllers. Start Windows PowerShell…
Deploying the SCCM Client with VMware Client Windows Guest Customization
Since SCCM is our configuration management tool of choice, the SCCM client needs to get installed on all of our newly provisioned VMs. I created a service account that only has read permission to the \\sccmserver\sms_sitecode\client share on the SCCM server. The client is installed from this location to ensure that we are always using the latest…
Provisioning a New Office 365 User and Mailbox from Exchange Hybrid via PowerShell
Working with many Office365 clients, I receive queries on how to go about provisioning users and mailboxes for an Exchange hybrid deployment. To begin with, let’s assume a couple things. We have a Windows 2012 R2 member server with Azure AD Connect (AAD Connect) version 1.1.105.00 (or newer) and the Azure AD Module for PowerShell installed;…
Add Alternate Email Address or Recovery Email Address for Office365 Administrator
In Office365, depending on the admin role of an account you may want to add an alternate email address for password recovery. This is a basically a self-service password reset for Administrators of Office365. Quick way to do this is with PowerShell:
1 2 3 4 5 6 7 8 9 10 11 12 |
#Connect to Office365 Import-Module MSOnline Connect-MsolService $O365Cred = Get-Credential $O365Session = New-PSSession –ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $O365Cred -Authentication Basic -AllowRedirection Import-PSSession $O365Session #Check if the user has an Alternate Email Address (Recovery Address) Get-MsolUser -UserPrincipalName mwasay@domain.com | select -ExpandProperty AlternateEmailaddresses #Check if the user has an Alternate Email Address (Recovery Address) Set-MsolUser -UserPrincipalName mwasay@domain.com -AlternateEmailAddresses mwasay@domain2.com |
If this setting is unset for an administrator, Office365 gives you a…
Map a network drive using PowerShell
Make sure you are using the latest version of PowerShell. On Windows 8/10 run it as administrator and type the following:
1 |
New-PSDrive –Name “Z†–PSProvider FileSystem –Root “\\fileserver01\share†–Persist |
Where: Z – is the Drive Letter Within ” ” is the path of the network share that will be presented as the root of the drive letter Z The -Persist parameter so…
Guide to migrate FRS to DFSR
For most users this article only applies if you have Window 2003/ 2003 R2 Domain Controller in your enviornment that you are planning to get rid off. Pretty soon I hope! 😉 SYSVOL is a folder shared by domain controller to hold its logon scripts, group policies and other items related to AD. All the…
The Lazy Way To Do Active Directory Inventory
From time to time admins have to run an inventory of what is running in the AD environment. This is a good practice for audits, inventory, removing decommissioned servers, or any other good reason. The details that are required are like when was computer/ server created, when was it last logged into, what is the…
Lists all users last logon time
As administrators we often want to check which users have not logged in for quite a while, or what accounts recently accessed a system, etc. The following script list all users and their last logon time. With the lastloggeduser.csv we can get fancy with excel to find differences based on age and more.
1 |
$([ADSI]"WinNT://$env:COMPUTERNAME").Children | where {$_.SchemaClassName -eq 'user'} | select @{l='name';e={$_.name}},@{l='LastLogin';e={$_.lastlogin}} | export-csv C:\scripts\lastloggedusers.csv |