question

GiladGershon-6057 avatar image
0 Votes"
GiladGershon-6057 asked AndreasBaumgarten edited

In Azure CLI there is a --no-wait command there is identical command on PowerShell?

The Azure CLI has a --no-wait command
Is there an identical command in powerShell?

windows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

LimitlessTechnology-2700 avatar image
1 Vote"
LimitlessTechnology-2700 answered AndreasBaumgarten edited

Hello @GiladGershon-6057,

As far as I am aware there is no such parameter built in. Normally what I do in my scripts is to run that line as a "job" so it will run in a different session and my main script can continue.

steps:
1. Save the line(s) you don't want to wait for in a PS1
2. change the line in your script for: Start-Job -FilePath <path\filename.ps1>

Hope this resolves your query,
Best regards,

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @GiladGershon-6057 ,

just be aware: If you use Start-Job and you end the PowerShell session the started job will be terminated as well. No matter if the job is finished or not.
Using Invoke-Command with -InDisconnectedSession will start a "disconnected/independant" PowerShell session which will run until it finished.


(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

Regards
Andreas Baumgarten

0 Votes 0 ·
AndreasBaumgarten avatar image
0 Votes"
AndreasBaumgarten answered GiladGershon-6057 commented

Hi @GiladGershon-6057 ,

using Invoke-Command with the -InDisconnectedSession option might be what you are looking for:
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/invoke-command?view=powershell-7.1


(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

Regards
Andreas Baumgarten

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

What I'm looking for is not to write a script, but to run command after command.
for example:
Run command to delete Resource Group in PowerShell, and move on without waiting for the deletion to end.

0 Votes 0 ·