我的域中较新的计算机上缺少Calc.exe。该脚本解决了该问题并将计算器快捷方式恢复到“开始”菜单:
Get-AppXPackage -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
$result = "powershell calculator fix ran"
$result | Out-File \\$computerlist\c$\smsflags\calculatorfix.exe
$TargetPath = "shell:AppsFolder\Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"
$ShortcutFile = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Calculator.lnk"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.TargetPath = $TargetPath
$Shortcut.Save()
是否可以针对保存在.csv或.txt文件中的域中的计算机列表运行此脚本?
答案 0 :(得分:1)
尝试一下:
$Computers = Get-Content -Path 'computerlist.txt'
Invoke-Command -ComputerName $Computers -ScriptBlock {
Get-AppXPackage -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
$result = "powershell calculator fix ran"
$result | Out-File 'C:\smsflags\calculatorfix.exe'
$TargetPath = "shell:AppsFolder\Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"
$ShortcutFile = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Calculator.lnk"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.TargetPath = $TargetPath
$Shortcut.Save()
}