powershell几点好用处

1. 从命令行发布Windows对话

  因为Windows PowerShell位对象而优化,可以向.NET Framework一样从命令行访问COM对象,下列命令告诉你的Vista机器发表"Windows Vista and PowerShell"字串.

  PS> $spVoice = new-object -com "SAPI.spvoice"

  PS> $spVoice.Speak("Windows Vista and PowerShell")

  2. 使用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)

  3. Windows PowerShell作为命令行存储计算器

  PowerShell可以完成基本的计算工作

  PS> 2*2

  不过,Windows PowerShell也可以快速解决存储问题,例如,备份11GB的数据需要多少个700MB的CD.

  PS> 11gb/700mb

  那么,需要多少个1000GB的存储来备份每个320GB,共425个的Vista桌面呢?

  PS > (320gb*425)/1000GB

  4. PowerShell 用作日历计算

  计算多少天到新年:

  PS> ([DateTime]"1/1/2007" -[datetime]::now).days
 5. 返回机器上某种类型文件的数量

  Windows Vista有许多类型的事件记录和组策略文件等.下列命令是返回当前目录及其子目录中VBScript, Bat 和 PowerShell 脚本的数量:

  PS> dir -include *.vbs, *.ps1, *.bat -recurse   group-object extension -noelement

  6. 从命令行收集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"

  7. 配置UAC(User Account Control)

  PS> set-itemproperty -path HKLM:SOFTWAREMICROSOFTWINDOWSCurrentVersionPoliciesSystem -name ConsentPromptBehaviorAdmin -value 0

  8. 管理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()
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值