I'm creating a C program to join several powershell scripts to facilitate their execution.
But before I run the scripts I need to connect with powersheel.
I need to run these commands:
$Session, $Credentials = C:\PowerShell\connect.ps1 |
Connect-AzureAD -Credential $Credentials |
Import-PSSession $Session -DisableNameChecking |
Set-ADServerSettings -ViewEntireForest $true
I tried to run the powershell command at the beginning of my C program but it opens a new powershell: system("powershell");
How can I connect my main.exe to powershell and then run the commands?