Gotove skripte

How can I check the version of Windows PowerShell installed on my machine?

A: To check the version of Windows PowerShell installed, run this cmdlet:

get-host

which will show the version of the PowerShell host.

PS C:\> get-host

Name             : Windows PowerShell ISE Host
Version          : 3.0
InstanceId       : ff53c294-38a7-4f48-b439-378843e45802
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterfac
e
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.Host.ISE.ISEOptions
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Also, you can check the built-in variable $PSVersionTable for the actual PowerShell version. Here’s the cmdlet:

$PSVersionTable

Below is an example of output returned when I entered the cmdt:

PS C:\> $PSVersionTable

Name                             Value
—-                             —–
WSManStackVersion                3.0
PSCompatibleVersions             {1.0, 2.0, 3.0}
SerializationVersion             1.1.0.1
BuildVersion                     6.2.9200.16398
PSVersion                        3.0
CLRVersion                       4.0.30319.269
PSRemotingProtocolVersion        2.2

_______________________________

How to: FIX: the trust relationship between this workstation and the primary domain failed

 

So this happens often, usually laptops but sometimes desktop and even servers fall victim to this issue. There are apparently a number of reasons why this happens, but the main reason seems to be lost connection between the ‘client/server’ and the Domain controllers. If the scheduled password change occurs while the server or client is unavailable or has been shut down, then the passwords stored in the server/client and the domain controllers for the computer account mismatch, and you will end up getting this error when trying to logon to the server. It can also appear differently, like if all service accounts stop functioning with events logged as a result, or similar that happens when the server is still running and you have been able to logon or simply never logged off. Here is how to fix it without leaving and rejoining the domain.

2 Steps total

Step 1: Getting in

If you know the local admin password – great! just click Switch User and log in as .\administrator and your password “.\” replaces the computer name in case you dont know it.

If you do not know local admin password but previously logged in with your domain credentials, you are still good. Unplug the network cable, disable wireless, then reboot the system. After reboot log in with you domain credentials and you should be able to get back in.

Step 2: Reestablishing Trust

Open PowerShell as administrator. Run this command sequence

 

$credential = Get-Credential – (enter domain admin account when prompted)

Reset-ComputerMachinePassword -Server ClosestDomainControllerNameHere                   -Credential $credential

and you are all set:)

Well that was easy, and did not require you to leave and rejoin the domain.