Good evening everyone,
Im trying to remove some stuff and it must be in a separate powershell window. The problem is than i cannot pass the path variable to that powershell Window, it should be something like this:
$path = "\\server01\test path"
Start-Process powershell -WindowStyle Normal {
Remove-Item -path "$path\file.txt" -Recurse -Force
}-Verb runas
any recommendations?
-Recurseif you only want to removefile.txt? Please explain what you need to remove, why it must be in a separate powershell window and also show us what your code does now (and what it should do). Edit your question and put that info in therestart-process powershell '& { param($b); echo $b;pause } "there"' -verb runasStart-Process' (here positionally implied)-ArgumentListparameter. If you do, it is invariably stringified, which results in its verbatim content (sans{and}) being passed, thereby preventing the use of variable values from the caller's scope. In order to incorporate the latter, you must pass the code as an expandable string ("...") instead, with embedded double-quoting around variable references as necessary. See the linked duplicate for details.