使用PowerShell脚本执行XML标记内的Command

时间:2017-02-17 12:00:54

标签: powershell xml-parsing

我是PowerShell脚本的新手,当我尝试通过PowerShell脚本执行XML标记内的命令时,我将该命令打印为文本而不是执行。

<Task>
    <RegistrationInfo>
        <URI>\Power\Test</URI>
    </RegistrationInfo>
    <Principals>
        <Principal id="Author">
            <UserId>S-1-5-21-928065147-2950777667-2078638527-1001</UserId>
            <LogonType>InteractiveToken</LogonType>
        </Principal>
    </Principals>
    <Settings>
        <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
        <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
        <Enabled>false</Enabled>
        <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
        <IdleSettings>
            <Duration>PT10M</Duration>
            <WaitTimeout>PT1H</WaitTimeout>
            <StopOnIdleEnd>true</StopOnIdleEnd>
            <RestartOnIdle>false</RestartOnIdle>
        </IdleSettings>
    </Settings>
    <Triggers>
        <CalendarTrigger>
            <StartBoundary>2017-02-13T17:30:00+05:30</StartBoundary>
            <ScheduleByDay>
                <DaysInterval>1</DaysInterval>
            </ScheduleByDay>
        </CalendarTrigger>
    </Triggers>
    <Actions Context="Author">
        <Exec>
            <Command>notepad.exe</Command>
        </Exec>
    </Actions>
</Task>

当我尝试下面提到的PS脚本时,我没有得到所需的输出。

 $xml = [xml](Get-Content "C:\Users\ACER\Desktop\Test.xml")
 $xml
 $xml.Task
 $xml.Task.Actions.Exec.Command

0 个答案:

没有答案