PowerShell: Restart Fails ‘Other Users Logged On’
Dec03

PowerShell: Restart Fails ‘Other Users Logged On’

KB ID 0001374 Problem If you intend to shutdown, or restart a remote computer using PowerShell, you may see the following error message; PS C:\> Restart-Computer “Computer-name“ Restart-Computer : This command cannot be run on target computer(‚ÄėComputer-name‚Äô) due to following error: The system shutdown¬†cannot be initiated because there are other users logged on to the computer. At line:1 char:1 + REstart-Computer...

Read More
Unable to Find a Default Server With Active Directory Web Services Running
Jan15

Unable to Find a Default Server With Active Directory Web Services Running

KB ID 0001275 Dtd 14/01/17 Problem I was trying to get a list of all users on a client’s domain that had either a logon script, profile, or a mapped drive that was being set on their AD user object. But when I ran the command I got this error; Get-ADUser : Unable to find a default server with Active Directory Web Services running. Solution Active Directory Web services was introduced in Server 2008 R2, but I was running the...

Read More
Move AD Group Members to an OU
Dec23

Move AD Group Members to an OU

KB ID 0001266 Dtd 23/12/16 Problem I got asked to do this at work this week, PLEASE BE AWARE, moving users about within AD may drastically change the way your ‘User Group Policies’ are being applied. So do some Group Policy Modelling beforehand, to avoid any problems. Solution In the example above, I’ve got ten users in a security group called ‘Source-Group‘. For simplicity, they are all in the same...

Read More
PowerShell – Updating Users Email Addresses In Active Directory
Jul05

PowerShell – Updating Users Email Addresses In Active Directory

KB ID 0001216 Dtd 05/07/16 Problem Note: I’m referring to the Email address value that is listed on the user object in Active Directory, this will not effect any Exchange Settings!A colleague asked me today if I had any PowerShell to update ALL¬†the users in a clients AD, to match their UPN to their Email addresses. A quick internet search turned up loads of handy scripts to update the UPN to mach the email address, but not the...

Read More
PowerShell – List All Domain Users and Their Last Logon Time
Nov17

PowerShell – List All Domain Users and Their Last Logon Time

KB ID 0000752 Dtd 24/05/13 Problem In the past I’ve looked at third party tools to do this but what if you wanted to use PowerShell? Solution 1. On your server paste the following script into Notepad; $NumDays = 0 $LogDir = ".Users-Last-Logon.csv" $currentDate = [System.DateTime]::Now $currentDateUtc = $currentDate.ToUniversalTime() $lltstamplimit = $currentDateUtc.AddDays(- $NumDays) $lltIntLimit = $lltstampLimit.ToFileTime()...

Read More
PowerShell Web Access
Nov17

PowerShell Web Access

KB ID 0001036 Dtd 18/02/15 Problem One of my goals for this year is to become more proficient with PowerShell. During my studies I came across PowerShell Web access and thought it was so cool, I’d have a play with it. What is PowerShell Web Access? It’s a web service that runs on a Server 2012 IIS web server. It lets you remote connect to that host (via https) and then launch a PowerShell secure connection to any machine...

Read More