- 工信部备案号 滇ICP备05000110号-1
- 滇公安备案 滇53010302000111
- 增值电信业务经营许可证 B1.B2-20181647、滇B1.B2-20190004
- 云南互联网协会理事单位
- 安全联盟认证网站身份V标记
- 域名注册服务机构许可:滇D3-20230001
- 代理域名注册服务机构:新网数码
一段power shell的代码 ,主要功能是批量重启IIS 具体的 Power shell 服务如下:
write-output 'Restarting IIS servers ................ ' $servers= 'server1' ,'Server2' $username='用户名' $password = ConvertTo-SecureString -String '密码' -AsPlainText -Force $credential =New-Object System.Management.Automation.PSCredential -argumentlist $username ,$password foreach($server in $servers){ $message= 'Restarting IIS server : '+$server write-output $message $sessions=New-PSSession -ComputerName $server -credential $credential Invoke-Command –Session $sessions -scriptBlock {restart-Service w3svc} $message= 'IIS server Restarted : '+$server write-output $message } write-output 'IIS servers Restarted ...................'
系统执行的逻辑是:
1用$credential =New-Object System.Management.Automation.PSCredential -argumentlist $username ,$password登录到远程服务器上
2 运用命令Invoke-Command –Session $sessions -scriptBlock {restart-Service w3svc} 逐个重启IIS Server
售前咨询
售后咨询
备案咨询
二维码
TOP