I am using OperationsManager module to work with SCOM, I need to find the somemanagementpack.mpb file information from SCOM which is already imported in SCOM an than need to delete the same somemanagementpack.mpb file locally based on the version
Below is the command I am using
Import-Module "OperationsManager"
New-SCOMManagementGroupConnection -ComputerName "DEVSCOM"
$mp = Get-SCManagementPack -BundleFile C:\Temp\somemanagementpack.mpb
$version = $mp.Version
$localVersion = "1.0.0.0"
if($version -gt $localVersion)
{
Remove-Item "C:\Temp\somemanagementpack.mpb" -Force
}
but when I am trying to remove it getting below error, I have also tried using Dispose method but nothing happens
The action can't be completed because the file is open