MoveCMObject.psm1
function GetCMUserCollection($ColName){
$ici = (get-location).path
$retour = Get-CMUserCollection -Name $ColName
Set-Location $ici
return $retour
}
function GetCMDeviceCollection($ColName){
$ici = (get-location).path
$retour = Get-CMDeviceCollection -Name $ColName
Set-Location $ici
return $retour
}
function GetCMCollection($ColName){
$ici = (get-location).path
$retour = Get-CMCollection -Name $ColName
if($retour){
$retour = GetCMUserCollection($ColName)
if(!$retour){$retour = GetCMDeviceCollection($ColName)}
}
Set-Location $ici
return $retour
}
function GetCMDeploymentType($DTName){
$ici = (get-location).path
$retour = Get-CMDeploymentType -Name $DTName
Set-Location $ici
return $retour
}
function GetCMApplication($AppName){
$ici = (get-location).path
$retour = Get-CMApplication -Name $AppName
Set-Location $ici
return $retour
}
function GetCMDriverPackage($DrvName){
$ici = (get-location).path
$retour = Get-CMDriverPackage -Name $DrvName
Set-Location $ici
return $retour
}
function GetCMPackage($PckName){
$ici = (get-location).path
$retour = Get-CMPackage -Name $PckName
Set-Location $ici
return $retour
}
function GetCMObjectType($ObjName){
$ici = (get-location).path
$retour = GetCMCollection($ObjName)
if($retour){$Global:CMObjectType = 'Collection'}else{$retour = GetCMDeploymentType($ObjName)}
if($retour){$Global:CMObjectType = 'DeploymentType'}else{$retour = GetCMApplication($ObjName)}
if($retour){$Global:CMObjectType = 'Application'}else{$retour = GetCMDriverPackage($ObjName)}
if($retour){$Global:CMObjectType = 'DriverPackage'}else{$retour = GetCMPackage($ObjName)}
if($retour){$Global:CMObjectType = 'Package'}
Set-Location $ici
return $retour
}
function MoveCMObject{
param($ObjName,[string]$Dest)
$erroractionpreference = 'silentlycontinue'
$ici = (get-location).path
if(!$thisfldr){$thisfldr = $PsScriptRoot}
if(!$thisfldr){$thisfldr = (Get-Location).path}
$Global:here = $thisfldr
set-location $here
if(!$CMDrive){$Global:CMDrive = (Read-Host "CM Site Code = ?").replace('\','').replace(':','') + ':\'}
[string]$DriveCM = $CMDrive.replace('\','')
if($Dest -match $DriveCM){$Dest = $Dest.replace($DriveCM,'').trimstart('\').trimend('\').replace('\\','\')}
$Dest = "$DriveCM\$Dest"
$GetCMObjectType = GetCMObjectType($ObjName)
set-location $CMDrive
$retour = Move-CMObject -InputObject $GetCMObjectType -FolderPath $Dest
Set-Location $ici
return $retour
}
/image%2F0881799%2F20140610%2Fob_a8c7fe_logo2.jpg)
Commenter cet article