Tuesday 9 October 2018

Powershell: Check Last Password Set Date and Time for an AD-User

To check when the password for an account in Active Directory was last set.
Just TYPE:

Get-ADUser -Filter 'name -like "Insert SamAccountName Here"' -Properties PasswordLastSet

Result:


Monday 8 October 2018

Powershell: All Properties of an Object in Active Directory

Sometimes you need to see all the properties of an object in Powershell.


When we type:

Get-ADObject -Filter 'Name -like "guest"' | fl

You get these properties in the response:








To get ALL the properties of  the object, TYPE:

Get-ADObject -Filter 'Name -like "guest"' -Properties *

Then you get the response:





Now we can choose any property we want to work with from the list.
Get-ADObject -Filter 'Name -like "guest"' -Properties whenCreated

This gets us:


Well, we got the property we wanted, but we got more than we wanted, getting some of the default properties as well.



To only get the property we want we need to type:

Get-ADObject -Filter 'Name -like "guest"' -Properties * | FT -Property whenCreated

Finally we are getting close with the date (in this case) below the property:



Now annoyingly we get a menu this time, with the object property name above the value.

To isolate the value, type:

Get-ADObject -Filter 'Name -like "guest"' -Properties * | Select-Object -ExpandProperty whenCreated



And off we go. Hopefully this helped you out.






Wednesday 25 April 2018

Hyper-V Manager Error Connecting to Windows 2012 R2 Host Server

If you come across the following error while trying to connect to a Windows 2012 R2 Server Hyper-V host from a Windows 2016 Server using Hyper-V Manager:




You can run the following command on the Windows 2012 R2 host server:
MOFCOMP %SYSTEMROOT%\System32\WindowsVirtualization.V2.mof


Should fix it right up for you.

Warning: Please be aware that this change will break the firmware function on generation 2 Guests. For instance, as illustrated below the option to choose boot order becomes very limited.

Sadly the only fix for this it to reinstall the Hyper-V Role on the server, so please be aware of it.






Tuesday 6 February 2018

Hyper-V 2016: Virtual Guest Stuck in Starting in SCVMM


I had a VM-guest get stuck in state "Starting..." in Virtual Machine Manager for a clustered Hyper-V system. 

Refreshing the guest, host or cluster did not help.
Restarting the VM-host where the VM-guest was stuck did not work either. 

Most options were greyed out when right-clicking the guest, only showing "Refresh" and "Connect or View" which in turn only showed network. 

Logging into the VM-Host where the guest was situated according to SCVMM showed in Hyper-V Manager that the guest was not on that host. 


After logging into the other hosts of the cluster I found the guest on one of the other hosts. VMM still showed it to be on the same (incorrect) host as before.

After some troubleshooting back and forth I finally tried opening up the Failover Cluster Manager on one of the hosts and went to Failover Cluster Manager - <Clustername> - Roles.

 I marked the VM-guest with the "Starting..."-problem and live migrated it to one of the other hosts.

This cleared the status in SCVMM and show the server nice and tidy on the host where I moved it.

Monday 5 February 2018

Powershell: Restart a Windows Server

To continue the tradition of using Powershell for normal activity we would otherwise do using the Windows Graphical Interface here is a quick intro to using the command Restart-Computer to restart your server or computer.


Thursday 1 February 2018

Powershell: Install all RSAT Tools on Windows Server 2016


To get all administrative tools installed easily on a Windows 2016 Server one simple cmdlet is available.

Powershell: Ipconfig command


A good way to get into a routine of learning Powershell is to do your usual command prompt commands in Powershell instead. For me ipconfig was one of those commands.