Showing posts with label Powershell. Show all posts
Showing posts with label Powershell. Show all posts

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.






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.

Wednesday, 31 January 2018

Powershell: Test a TCP port to see if it is open


Instead of having the trouble of installing Putty or some other program to every new server or workstation you can easily check if a TCP port is open to a specific IP-Address or DNS name with powershell.

Monday, 11 December 2017

Powershell: How to Clear a Variable


Clearing a variable is quite straight forward. One thing to keep in mind though is to leave the $ out of the command.
Also if the variable is an array, we need to remember to remake it into an array again.

Powershell: Compare Files


An easy way to compare files with powershell.

Powershell: Output SCVMM baseline updates to file by KBarticle when patching fabric


Sometimes, you just need to output VMM baseline updates to file. When comparing patches for instance.