powershell禁用计算机,禁用PowerShell的自动更新

$SCRIPT:AutoUpdateNotificationLevels= @{

0=\"Not configured\";

1=\"Disabled\";

2=\"Notify before download\";

3=\"Notify before installation\";

4=\"Scheduled installation\"

}

$SCRIPT:AutoUpdateDays=@{

0=\"Every Day\";

1=\"Every Sunday\";

2=\"Every Monday\";

3=\"Every Tuesday\";

4=\"Every Wednesday\";

5=\"Every Thursday\";

6=\"Every Friday\";

7=\"Every Saturday\"

}

Function Get-WindowsUpdateConfig

{

$AUSettings = (New-Object -com \"Microsoft.Update.AutoUpdate\").Settings

$AUObj = New-Object -TypeName System.Object

Add-Member -inputObject $AuObj -MemberType NoteProperty -Name \"NotificationLevel\" `

-Value $AutoUpdateNotificationLevels[$AUSettings.NotificationLevel]

Add-Member -inputObject $AuObj -MemberType NoteProperty -Name \"UpdateDays\" `

-Value $AutoUpdateDays[$AUSettings.ScheduledInstallationDay]

Add-Member -inputObject $AuObj -MemberType NoteProperty -Name \"UpdateHour\" `

-Value $AUSettings.ScheduledInstallationTime

Add-Member -inputObject $AuObj -MemberType NoteProperty -Name \"Recommended updates\" `

-Value $(IF ($AUSettings.IncludeRecommendedUpdates) {\"Included\"} else {\"Excluded\"})

$AuObj

}

Function Set-WindowsUpdateConfig

{

Param (

[Parameter()]

[ValidateRange(0,4)]

[int]

$NotificationLevel ,

[Parameter()]

[ValidateRange(0,7)]

[int]

$Day,

[Parameter()]

[ValidateRange(0,24)]

[int]

$hour,

[Parameter()]

[bool]

$IncludeRecommended

)

$AUSettings = (New-Object -com \"Microsoft.Update.AutoUpdate\").Settings

if ($NotificationLevel) {$AUSettings.NotificationLevel =$NotificationLevel}

if ($Day) {$AUSettings.ScheduledInstallationDay =$Day}

if ($hour) {$AUSettings.ScheduledInstallationTime=$hour}

if ($IncludeRecommended) {$AUSettings.IncludeRecommendedUpdates=$IncludeRecommended}

$AUSettings.Save()

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值