The Windows PowerShell remoting features are supported by the WS-Management protocol and the Windows Remote Management (WinRM) service.
So, Windows PowerShell is a new Windows command-line shell designed for system administrators.
If you got this error is shown below that is need to make something.
1 2 3 | File D:\test-powershell.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details. At line:0 char:0 |
First, you just need to learn a few tricks for running Windows PowerShell scripts.
You can verify the settings for your execution policy by typing the following at the PowerShell command prompt.
Also, you need to set your execution policy to RemoteSigned.
Get-ExecutionPolicy and Set-ExecutionPolicy RemoteSigned
See the example below from PowerShell
1 2 3 4 5 6 7 8 9 10 11 12 | Windows PowerShell Copyright (C) 2009 Microsoft Corporation. All rights reserved. PS C:\Users\YOU> Get-ExecutionPolicy Restricted PS C:\Users\YOU> Set-ExecutionPolicy RemoteSigned Execution Policy Change The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose you to the security risks described in the about_Execution_Policies help topic. Do you want to change the execution policy? [Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y |
Now you can use the power of PowerShell.
1 2 3 4 5 | PS D:\> .\test-powershell.ps1 Name : Default System BIOS Version : ACRSYS - 20080731 Manufacturer : American Megatrends Inc. SMBIOSBIOS Version : 207 |
Let’s the code source of the script. Is a simple script to display BIOS properties.
1 2 3 4 5 6 7 8 9 10 11 | param( [string]$strComputer = "." ) $colItems = get-wmiobject -class "Win32_BIOS" -namespace "root\CIMV2" -computername $strComputer foreach ($objItem in $colItems) { write-host "Name :" $objItem.Name write-host "Version :" $objItem.Version write-host "Manufacturer :" $objItem.Manufacturer write-host "SMBIOSBIOS Version :" $objItem.SMBIOSBIOSVersion write-host } |
I hope this tutorial helped you.