So I’ve got a bunch of Posh scripts in a folder, I want to call them all from a “caller” script at once. Something like the below:
$folder = "C:\Users\SameerMhaisekar\OneDrive - SquaredUp\Documents\PowerShell\MyScripts"
$scripts = $folder | Get-ChildItem | select name
foreach ($script in $scripts){
$output = $PSScriptRoot+"\$script"
&$output
}
The error I get is
& : The term ‘@{Name=master.ps1}’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:5 char:2
- &$output
-
+ CategoryInfo : ObjectNotFound: (\@{Name=master.ps1}:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException