I have some custom powershell cmdlets in several scripts, one of which i've loaded an executed as such in C#
string Script2 = File.ReadAllText(@"C:\blabla\blabla\ScriptPowershell\TestCheck.ps1");
shell.Commands.Clear();
shell.AddScript(Script2, false);
shell.Invoke();
shell.Commands.Clear();
shell.AddCommand("TestCheck").AddParameter("ServerName", $"{serverId}").AddParameter("ServerPort", $"{serverPort}");
Collection<PSObject> psObjects = shell.Invoke();
The main issue with this is that if I publish and install this app on another computer that surely might not have this script at the same exact directory, the cmdlet will not work.
QUESTION: Is there a way to publish the app with the scripts joined to it, so that it doesn't need to search in the users computer for the scripts? Or at least be present in the same directory as the.exe
Any suggestion to solve this problem is welcome.
Thank you !
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.