start-process
1 TopicCan't pass arguments from one script to another script
Hey! I am trying to find a way to pass arguments I provide while originally running my script to a version of the script which reruns if I don't have admin permissions. When I have tried what seems like 100 ways to do this I either gets errors or I get nothing with the powershell windows just closing immediately. I've tried a few ways to see if there is any error output as it resolved an earlier issue I ran into (sorta), but this time I can't seem to get any output. My current code looks like this: param ( [bool]$RepairMenu, [string]$RunStage ) # Check for running as admin if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { Write-Host "Attempting to Elevate!" # Re-launch the script elevated Start-Process powershell.exe -Verb RunAs -ArgumentList "-File `"$PSCommandPath`"" } I would just run my script from within it's directory: .\logic.ps1 -RepairMenu $true I most commonly find some variable of this: -RepairMenu `"$RepairMenu`"" should be added within my arguments list, but regardless of how I add it to the list whether it's comma separated, space separated, anything, the script just exits with no reports of anything. As provided the script will run and any code to do with the parameters passed isn't til later in the script and before that there would be some results I'd see in C: drive. I have no idea where I am going wrong with this. Not that I hope this is important for my end result of this script, it might be for another involved with it and so I want to squash this now to make my testing prove that my script will work worst case scenario. Any help would be appreciated!3KViews0likes2Comments