Should this work?
waithidden {pathname of file ((it as string) of value "Path" of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" of native registry)} -executionpolicy remotesigned -File "c:\temp\mdfi\*.ps1"
I have no idea the name of the .ps1 that will be in that folder as it chooses one from over 150 files based on the domain name of the server to place inside that folder so I really need it to run any old powershell (there will be only one in that folder).
Iād suggest just trying the PowerShell command on a command line itself; I donāt know whether PowerShell accepts a wildcard for the script nameā¦but if thereās only one file there, you could always just use a second relevance substitution to retrieve the filename?
1 Like
I never thought about using the 2nd relevance idea
So essentially getting the filename of the ps1 as a parameter then running it using that?
Yes, something like
waithidden {pathname of file ((it as string) of value "Path" of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" of native registry)} -executionpolicy remotesigned -File "{pathname of find file "*.ps1" of folder "c:\temp\mdfi"}"
The singular use of āfileā and āfolderā there is intended, to throw a āsingular expressionā error and abort the script if there do happen to be more than one .ps1 files in that folder.
I went with this as I didnāt see you replied
parameter "ps1"="names of files whose (name of it as lowercase ends with ".ps1") of folder "C:\tmp""
waithidden {pathname of file ((it as string) of value "Path" of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" of native registry)} -executionpolicy remotesigned -File "c:\temp\mdfi\"{parameter "ps1"}""
Havenāt tested it yet though
I think youāll need to delete the extra quotes outside the {parameter}
substitution but otherwise yeah that should worktoo
1 Like
This should be it now (again not tested as the guy I need is off shift until tomorrow)
parameter "ps1"="{names of files whose (name of it as lowercase ends with ".ps1") of folder "C:\tmp")}"
waithidden {pathname of file ((it as string) of value "Path" of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" of native registry)} -executionpolicy remotesigned -File "c:\temp\mdfi\{parameter "ps1"}"