简体   繁体   中英

Powershell Problem with passing Variables through Start-Process

i have a Problem with a new Script i am working on. This Script includes a Command where i want to execute another Programm with arguments, supportet by this Programm. At first i will get input from the PowerShell script and save this to variables, than put those variables into the argumentslist of the start process, to get it pass through the Programm. But this doesnt work as i wanted. I always see that the Programm wrotes a log in where it wrotes the variable as Name not what is inside the variable. I tried different ways but it doesnt want to work. This is the Code with some test variables:

 $goal = "dlr-1-ws240"
 $newdate = (Get-Date).AddDays(7) | Get-Date -Format "yyyy-MM-dd-12-00-00"
 $adminurl = "w10_lgrm.admin_" + $goal + "_b"
 $newmember = $env:USERNAME + ":" + $newdate
 $argulist = "-o AddMembers -service $adminurl -members $newmember"

 Start-Process "C:\Cometo V.2.5\Bin\CometClient.exe" -Argumentlist {-o AddMembers -service $adminurl -members $newmember /log}

It always detecs $newmember as the Name "$newmember" and not what its inside.

I am thankfull for every help. Thanks

&{
    param(
        [int]$packageCount,
        [string]$hostName
    )

Start-Process "ping.exe" -ArgumentList "$hostName -n $packageCount"
} -packageCount 10  -hostName "google.com"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM