I have a powershell script, that I am developing on local PC and deploying onto Azure. The script uses credentials, that are handled differently on PC and in Azure. I therefore need to reliably check whether the script is running on the PC or on Azure.
I cannot find any command, that tells me the answer. I hope you can help.
I know this is old but if the goal is to just be able to run the script locally for development then this should work.
if ($env:computername -ne "<EnterYourComputerNameHere>") {
# Script is running in Azure
# use Azure Automation credentials
} else {
# Script is running locally
# us Local credential process
}
enter code here
#do the remainder of your work
I checked in Azure for specific environment variables. Looks like this would be more appropriate in this case:
if ($env:AUTOMATION_ASSET_ACCOUNTID) {
"Running in Azure Automation"
} else {
"Running outside of Azure Automation"
}
I hope that helps a little bit more.
Welcome to StackOverflow: You can use multiple ways:
Send logs to output-stream:
https://docs.microsoft.com/en-us/azure/automation/automation-manage-send-joblogs-log-analytics
Hope this helps!
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.