Chcę usunąć zdalnie większość Built-in Apps na komputerach w domenie.
W przypadku jednej maszyny próbuję tak:
Invoke-Command -ComputerName Komputer -ScriptBlock -Credential Administrator_lokalny `
{
#dla aktualnych userów
Get-AppxPackage -AllUsers | Where-Object { $_.PackageFullName -notlike "*WindowsCalculator*" -and $_.PackageFullName -notlike "*WindowsStore*" -and $_.PackageFullName -notlike "*Windows.Photos*" } | Remove-AppxPackage -ErrorAction SilentlyContinue | Out-Null
#dla nowych userów
Get-AppxProvisionedPackage -Online | where { $_.Displayname -notlike "*WindowsCalculator*" -and $_.Displayname -notlike "*WindowsStore*" -and $_.Displayname -notlike "*Windows.Photos*" } | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue | Out-Null
}
I nic nie wychodzi poza:
#dla nowych userów
Get-AppxProvisionedPackage -Online | where { $_.Displayname -notlike "*WindowsCalculator*" -and $_.Displayname -notlike "*WindowsStore*" -and $_.Displayname -notlike "*Windows.Photos*"} | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue | Out-Null
Oczywiście wiadomo, że usługa WinRM jest włączona.
Próbuję też w sccm-ie 2012 R2 SP1 skryptu:
#dla aktualnych userów
Get-AppxPackage -AllUsers | Where-Object { $_.PackageFullName -notlike "*WindowsCalculator*" -and $_.PackageFullName -notlike "*WindowsStore*" -and $_.PackageFullName -notlike "*Windows.Photos*" } | Remove-AppxPackage -ErrorAction SilentlyContinue | Out-Null
#dla nowych userów
Get-AppxProvisionedPackage -Online | where { $_.Displayname -notlike "*WindowsCalculator*" -and $_.Displayname -notlike "*WindowsStore*" -and $_.Displayname -notlike "*Windows.Photos*" } | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue | Out-Null
Albo:
$AppsList = (Get-AppxPackage -AllUsers | Where-Object { $_.PackageFullName -notlike "*WindowsCalculator*" -and $_.PackageFullName -notlike "*WindowsStore*" -and $_.PackageFullName -notlike "*Windows.Photos*"}).Name
ForEach ($App in $AppsList)
{
$PackageFullName = (Get-AppxPackage $App).PackageFullName
if ((Get-AppxPackage $App).PackageFullName)
{
Remove-AppxProvisionedPackage -Online -Packagename $PackageFullName -ErrorAction SilentlyContinue | Out-Null
Remove-AppxPackage -Package $PackageFullName -ErrorAction SilentlyContinue | Out-Null
}
}
I nic nie wychodzi poza ...Remove-AppxProvisionedPackage.