powershell PowerShell:[SMP]运行广告

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell PowerShell:[SMP]运行广告相关的知识,希望对你有一定的参考价值。

[CmdletBinding(SupportsShouldProcess=$True,DefaultParameterSetName="None")]
PARAM(
	[Alias("Name")]
	[Parameter(Mandatory = $false, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName="p1")]
	[string[]]
	$ComputerName = $env:COMPUTERNAME
	,
    [Parameter(Mandatory = $false, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName="p1")]
	[Guid] 
	$taskGuid = [System.Guid]::Empty()
)

begin {
	
}

process {
	foreach ($ComputerName In $ComputerName) {
	    try {
		    $IAeXClientType = [System.Type]::GetTypeFromProgID("Altiris.AeXClient", $ComputerName, $true)
		    try {
			    $IAeXClient = [System.Activator]::CreateInstance($IAeXClientType)
		        $IAeXSWDAgent = $IAeXClient.ClientPolicyMgr.ClientAgent("Altiris.SWD")
				Write-Host "Executing $($IAeXSWDAgent.ManagedDelivery($taskGuid.ToString('B')).Name) on $($ComputerName)..." -NoNewline
				$IAeXSWDAgent.RunAdvertisement($taskGuid.ToString('B'), 0)
		        Write-Host "Success" -ForegroundColor Green
		    } catch {
	    	    Write-Host "Failed. $($_.Exception.InnerException.Message)" -ForegroundColor Red
		    }
	    } catch {
		    Write-Host "Failed. $($_.Exception.InnerException.Message)" -ForegroundColor Red
	    } finally {
		    Remove-Variable -Name IAeXClient -ErrorAction SilentlyContinue
		    Remove-Variable -Name IAeXClientType -ErrorAction SilentlyContinue
	    }
	}
}

end {
}

以上是关于powershell PowerShell:[SMP]运行广告的主要内容,如果未能解决你的问题,请参考以下文章

powershell PowerShell:启动PowerShell作为其他用户提升

powershell [提示输入powershell] #powershell #input #prompt

powershell 测量PowerShell命令或PowerShell脚本的速度

powershell远程下载exe并执行

powershell 使用啥端口

powershell PowerShell使用PowerShell创建本地管理员帐户