I want to execute a powershell script from C# code. I don't want to store my powershell script on any folder. script is kind of BIG and it has a parameters a "List" and "string", how to do this.
$ComputerName = "win12"
$username="administrator"
$password="passw0rd@12"
$secstr = New-Object -TypeName System.Security.SecureString
$password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
$fname="v.exe"
$fname="C:\"+$fname
$cr = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr
$Session = New-PSSession -ComputerName $ComputerName -Credential $cr
Invoke-Command -Session $Session -ScriptBlock {
Start-Process -FilePath $($args[0]) -ArgumentList '/a' -Verb runas -WindowStyle Normal
$process=[io.path]::GetFileNameWithoutExtension( $($args[0]));
$a = (Get-Process -Name $process)
$a.PriorityClass = [System.Diagnostics.ProcessPriorityClass]::RealTime
} -ArgumentList $fname
this is my powershell script.