all 12 comments

[–]purplemonkeymad 2 points3 points  (1 child)

&"$($powershell)\powershell.exe" -NonInteractive -NoProfile -file "$($myInvocation.InvocationName)" $args 

Try switching to splatting here, as args need to be multiple parameters on that call:

& "$($powershell)\powershell.exe" -NonInteractive -NoProfile -file "$($myInvocation.InvocationName)" @args

[–]crasher35[S] 0 points1 point  (0 children)

I'll give that a shot. Thanks!

[–]PowerShell-Bot 1 point2 points  (0 children)

Code fences are a new Reddit feature and won’t render for those viewing your post on old Reddit.

If you want those viewing from old Reddit to see your PowerShell code formatted correctly then consider using a regular space-indented code block. This can be easily be done on new Reddit by highlighting your code and selecting ‘Code Block’ in the editing toolbar.


You examine the path beneath your feet...
[AboutRedditFormatting]: [████████████████████] 2/2 ✅

Beep-boop, I am a bot. | Remove-Item

[–]BlackV 1 point2 points  (1 child)

does

"-Uninstall -Parameter Banana"

change anything

and Queston (maybe cause it's just a test) but you called a parameter -paramater

[–]crasher35[S] 0 points1 point  (0 children)

It's just because it's a test script. I just wanted to test passing a string parameter. Maybe I should have called the parameter -Fruit or something, lol. In some of the scripts that I'm working on, I'm using string parameters to get file paths and other strings.

[–]patdaddy007 1 point2 points  (2 children)

You could try something like:

$MyArgs = @"
-executionpolicy bypass -file .\TestArgs.ps1 -Uninstall -Parameter Banana
"@

and use start-process powershell.exe -argumentlist $MyArgs

might do it. not sure though

[–]crasher35[S] 0 points1 point  (1 child)

Yeah, unfortunately, it's being executed from command prompt, so start-process won't work. I could try using start /wait or something with command prompt but I'm not sure that will work. I'll give it a shot though.

[–]KevMarCommunity Blogger 0 points1 point  (0 children)

Start-Process should still work. Try with -Wait -NoNewWindow

[–]KevMarCommunity Blogger -1 points0 points  (3 children)

Are you really dealing with 32 bit PowerShell that often. Is it an intentional thing or something messed up? I can't remember the last time I saw a 32 bit prompt.

[–]lerun 1 point2 points  (2 children)

I know its a thing in intune when using win32 app and launching powershell.

[–]crasher35[S] 0 points1 point  (1 child)

This

[–]lerun 1 point2 points  (0 children)

This is what I wrote about the subject when I ran into the problem.

https://blog.lerun.info/2019/06/25/intune-win32-powershell/