6. 使用Windows PowerShell访问诸如Windows Media Player 11等的应用程序
PS> $band = "The Posies"
PS> $player = New-object -com wmplayer.ocx
PS> $playlist = $player.mediacollection.getbyauthor($band)
PS> $player.openPlayer($playlist.item(0).sourceurl)
7. Windows PowerShell作为命令行存储计算器
PowerShell可以完成基本的计算工作
PS> 2*2
不过,Windows PowerShell也可以快速解决存储问题,例如,备份11GB的数据需要多少个700MB的CD.
PS> 11gb/700mb
那么,需要多少个1000GB的存储来备份每个320GB,共425个的Vista桌面呢?
PS > (320gb*425)/1000GB
8. PowerShell 用作日历计算
计算多少天到新年:
PS> ([DateTime]"1/1/2007" -[datetime]::now).days
9. 返回机器上某种类型文件的数量
Windows Vista有许多类型的事件记录和组策略文件等.下列命令是返回当前目录及其子目录中VBScript, Bat 和 PowerShell 脚本的数量:
PS> dir -include *.vbs, *.ps1, *.bat -recurse group-object extension -noelement
10. 从命令行收集Windows System Assessment Tool数据
PS> get-wmiobject win32_winsat format-table __SERVER, *SCORE -autosize
PS> get-wmiobject win32_winsat select *score out-chart -Title "System Assessment Scores by PowerGadgets"
11. 配置UAC(User Account Control)
PS> set-itemproperty -path HKLM:SOFTWAREMICROSOFTWINDOWSCurrentVersionPoliciesSystem -name ConsentPromptBehaviorAdmin -value 0
12. 管理BitLocker
PS > $drives = get-wmiobject -namespace rootCIMv2SecurityMicrosoftVolumeEncryption -class Win32_EncryptableVolume
PS> $drives format-table DriveLetter, PersistentVolumeID -autosize
PS> $BitLockDrive = $drives[0]
PS> $BitLockDrive.GetProtectionStatus()
PS> $BitLockDrive.DisableKeyProtectors()
PS> $BitLockDrive.EnableKeyProtectors()