Hello Varma
Welcome to Microsoft Q&A Platform, thanks for posting your query here.
If you're creating VM's manually from the Azure portal and want to execute PowerShell commands on them immediately after creation without logging into the VM, you can use Azure Custom Script Extension.
Ref: https://learn.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-windows
While deploying the VM from Azure Portal, you can add the Extension.
Store your PowerShell script in a publicly accessible location, such as Azure Storage, GitHub, or any other publicly accessible URL.
Extension Details on the Azure Portal:
Provide the URL to your PowerShell script in the extension settings.
Save the extension settings and proceed with the VM creation process.
Once the VM is created, Azure will automatically execute the PowerShell script specified in the Custom Script Extension on the VM.
By using Azure Custom Script Extension, you can automate the execution of PowerShell commands on Azure VMs immediately after they are created, without the need for manual intervention or logging into the VM.
Hope this helps.
If the suggested response helped you resolve your issue, please 'Accept as answer', so that it can help others in the community looking for help on similar topics.