administrator
PS> Get-Module -ListAvailable | select name Name ---- CimCmdlets Microsoft.PowerShell.Archive Microsoft.PowerShell.Diagnostics Microsoft.PowerShell.Host Microsoft.PowerShell.LocalAccounts Microsoft.PowerShell.Management Microsoft.PowerShell.Security Microsoft.PowerShell.Utility Microsoft.WSMan.Management PackageManagement Pester PowerShellGet PSDesiredStateConfiguration PSDiagnostics PSReadLine
You can create a remote session to a machine running a copy of Windows PowerShell (in this case, PowerShell5.1):
PS> $s = New-PSSession -ComputerName W16DSC01 PS> Invoke-Command -Session $s -ScriptBlock {Get-Process l*} | Format-Table -AutoSize NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName PSComputerName ------ ----- ----- ------ -- -- ----------- -------------- 23 10.09 32.87 0.59 740 1 LogonUI W16DSC01 30 5.77 8.96 1.22 524 0 lsass W16DSC01
Cmdlets that aren’t part of PowerShell Core can be accessed on the remote machine:
PS> Invoke-Command -Session $s ` -ScriptBlock {Get-WmiObject -Class Win32_OperatingSystem} SystemDirectory : C:\Windows\system32 Organization : BuildNumber : 14393 RegisteredUser : Windows User SerialNumber : 00376-30816-46802-AA030 Version : 10.0.14393 PSComputerName : W16DSC01
No comments:
Post a Comment