Powershell脚本需要调用域用户名和密码

时间:2017-02-22 06:47:58

标签: powershell

我编写了一个带有少量测试的验证脚本,并且借助工具在每台机器上本地运行脚本。但是为了在脚本部分下面成功运行要调用的域用户名和密码。

任何人都可以帮我添加用户名和密码来调用以下脚本(例如:用户名:oim \ test,密码:test @ 123)

if (($ImageName -like "*devel*") -or ($ImageName -like "*hosted*"))
    {
        #$ADE1 = Invoke-Expression ('C:\ade\bin\ade.exe | select-string -pattern "begintrans"') | out-string ; $ADE = $ADE1.trim().split("")[1]
        Invoke-Expression ('C:\ade\bin\ade.exe | select-string -pattern "begintrans"') > C:\Temp\ade_check.txt 
        $ADE1 = Get-Content C:\Temp\ade_check.txt | Select-String "begintrans" | out-string ;  $ADE = $ADE1.trim().split(" ")[1]


        if ($ADE -eq "begintrans")
        {
        $ADE = "ADE Installation Success"


        Add-Content $report "<tr>"
            Add-Content $report "<td bgcolor= 'White'  height='30' align=center><B>17</B></td>"
        Add-Content $report "<td bgcolor= 'White'  height='30' align=left><B>ADE</B></td>"
        Add-Content $report "<td bgcolor= 'Aquamarine'  height='30' align=left><B>$ADE</B></td>"
        Add-Content $report "</tr>"

echo "ADE = ADE Installation Success"

        }

        if ($ADE -eq $null){
        $ADE = "ADE Installation Failed"


        Add-Content $report "<tr>"
        Add-Content $report "<td bgcolor= 'White'  height='30' align=center><B>17</B></td>"
        Add-Content $report "<td bgcolor= 'White'  height='30' align=left><B>ADE</B></td>"
        Add-Content $report "<td bgcolor= 'red'  height='30' align=left><B>$ADE</B></td>"
        Add-Content $report "</tr>"

echo "ADE = ADE Installation Failed"
        }

    }
    else
        {
        if (($ImageName -like "*simple*") -or ($ImageName -like "*BareOS*")){

        $ADE = "BareOS, ADE Not Installed"


        Add-Content $report "<tr>"
        Add-Content $report "<td bgcolor= 'White'  height='30' align=center><B>17</B></td>"
        Add-Content $report "<td bgcolor= 'White'  height='30' align=left><B>ADE</B></td>"
        Add-Content $report "<td bgcolor= 'Yellow'  height='30' align=left><B>$ADE</B></td>"
        Add-Content $report "</tr>"

echo "ADE = BareOS, ADE Not Installed"
        }
        }

1 个答案:

答案 0 :(得分:0)

您想要使用 Invoke-Command cmdlet。它具有您想要的 -Credentials 参数。像这样:

it('expects fromDay to be defined', function() {
   vm = $controller('EntryAddController', { $scope: $scope });

   expect(vm.fromDay).toBeDefined();
});