I have following line of code in my script which I'm running from my management laptop to servers. Code is inside of scriptblock
# If a proxy server is needed, execute these commands with the proxy URL and port.
[Environment]::SetEnvironmentVariable("https_proxy","http://{proxy-url}:{proxy-port}","Machine")
$env:https_proxy = [System.Environment]::GetEnvironmentVariable("https_proxy","Machine")
# For the changes to take effect, the agent service needs to be restarted after the proxy environment variable is set.
Restart-Service -Name himds
# Install the package
msiexec /i c:empAzureConnectedMachineAgent.msi /l*v c:empinstallationlog.txt /qn | Out-String
# The agent service needs to be restarted after the proxy environment variable is set in order for the changes to take effect.
Restart-Service -Name himds
# Run connect command
& "$env:ProgramFilesAzureConnectedMachineAgentazcmagent.exe" >> $logfolder$logfile connect `
--service-principal-id $appId `
--service-principal-secret $password `
--resource-group $resourceGroup `
--tenant-id $tenantId `
--location $location `
--subscription-id $subscriptionId
problem is that I don't get any output of that in my Powershell (on my management laptop) screen when running the script. I know that running that exe gives output. Output should look something like when running on local machine or when using following command end of script
$output | Out-File -FilePath .AzureArc.txt -append
Tried also Start-Transcript and Stop-Transcript but did not display logs neiher.
Tips what should I try so that I would get logs to show on my screen while script i
EDIT: Added pretty much whole code from scriptblock. Added also >> $logfolder$logfile to end of azcmagent.exe which made that I was able to collect logs to file but were not able do get them to show on Powershell while running script.
question from:
https://stackoverflow.com/questions/65842893/powershell-dont-give-output-after-running-exe 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…