Windows Powershell Notes
PS C:\> Get-ExecutionPolicy
if restricted
PS C:\> Set-ExecutionPolicy RemoteSigned
From dos : powershell c:\monscript.ps1
$cred = Get-Credential -Credential contoso\administrator
Get-WinEvent -LogName System -ComputerName NomDeMachine -Credential $cred
Il est bien évidement possible d’exécuter un script powershell depuis l’interpréteur Powershell en tapant la commande suivante:
.\nomduscript.ps1
$computers = “c1″,”c2”
Write-Output $computers
Write-Output $pingreturns[1]
==========================================
Get-BiosVersionUseArray.ps1
$computers = “hyperv”,”hyperv-box”
Get-WmiObject -Class win32_bios -cn $computers |
Format-table __Server, Manufacturer, Version -AutoSize
==========================================
Get-BiosVersionQueryAD.ps1
Import-Module -Name ActiveDirectory
Get-ADComputer -filter * |
Foreach-Object {
Get-WmiObject -Class win32_bios -cn $_.name -EA silentlyContinue |
Select-Object __Server, Manufacturer, Version } |
Format-Table -Property * -AutoSize
=====================================
