Azure module installation in Powershell - azure

I am trying to install azure module but it is showing the error
"unable to download the list of available providers, Check your internet connection.

Check your proxy settings and your firewall rule to be sure everything is working fine. If not working, you could download the module to your local computer and import it to the powershell.
Import-Module c:\windows\uyhe.ps1
Ensure the Execution-Policy is RemoteSigned
Set-ExecutionPolicy RemoteSigned
Hope this helps

Related

"Connect-MsGraph' is not recognized as the name of a cmdlet

I have a couple of PowerShell scripts that can run using Windows PowerShell with no issue.
As soon as I run them in VS Code on the same computer, I get "Connect-MsGraph' is not recognized as the name of a cmdlet,
I have installed the same Microsoft.Graph.Intune and other relevant AAD modules for both Windows PowerShell and VS Code.
Any idea why I can't run them in the VS Code?
Thanks
Connect-MsGraph' is not recognized as the name of a cmdlet,
The issue happens because of the VS code is not able to access the PSModulePath in the system or it happens if you are not using the latest Microsoft.Graph SDK.
Try to install the module in a default path
Install-Module -Name Microsoft.Graph -RequiredVersion 1.2.0
Refer here if in your system default path contains OneDrive.
After adding the required modules in a default path try to restart the VS Code and System.
References
Connect MS Graph in VS Code

Cannot uninstall Azure CLI 2.0.75

I need to update Azure CLI, but I realized I had installed Azure CLI in 2019 and never update it since. I This is a Windows 10 machine. When I try to uninstall, by going to 'Apps & features' and uninstalling Microsoft Azure CLI, I see the following:
Screenshot
Error: Click OK to try again, or enter an alternate path to a folder containing the installation package 'azure-cli-2.0.75 (1).msi' in the box below.
The challenge, however, is that I am not able to find that particular version of the msi anywhere. I would greatly appreciate if someone could kindly point me in the right direction :)
You can uninstall the azure cli using the below command
Remove-Module -Name Az -ErrorAction SilentlyContinue
Uninstall-Module -Name Az -AllVersions
Using this one it will automatically uninstall in silent mode.

Cloudn't register-PSRepository in my Windows10 for installing Azure PowerShell

I want to install Azure PowerShell in my windows 10, but I met an error message, I tried to find the reason for the error and found there was no package when I ran Get-PSRepository.
Background:
Install azure with code as below:
Install-Module -Name Az -AllowClobber -Scope AllUsers
Install-Module -Name Az -Repository PSGallery -Force
Error message:
Can't find the package at C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1748
Register-PSRepository -Default
Get-PSRepository shows can't find the package.
net winhttp show proxy shows without proxy server
what should I do to install the azure PowerShell?
Based on your error message, it seems that you have connection issue to powershell gallery
So, my first suggestion is to check your network environment work. Also remember to check your system proxy settings.
If your network has no problem, you may download package manually and then install modules from the downloaded nuget package
Another choice is to use Azure Cloud Shell
Hope the above could be helpful to you!

Installing Az 2.8.0 Powershell Module on Azure Dev Ops agent

I am using Azure Dev Ops build agents to do all my CI/CD. I am having trouble installing Az Powershell Module version 2.8.0 on the build agent. I need that particular version because a lot of new APIs have been released on that version when compared to 2.6.0. Installing 2.8.0 on the build agent before running my build process results in failure. As you can see here 2.8.0 is not yet installed on the base images for these agents. If anyone has some tips on how I can consume this specific module that would be really helpful. In the mean time I have opened an issue to add the version
Use below script in Powershell task to install Az 2.8.0 into Hosted linux agent:
Install-Module -Name Az -RequiredVersion 2.8.0 -Force -AllowClobber
Get-InstalledModule #Just print out the details to confirm whether `Az 2.8.0` has been installed successfully
You can see Az 2.8.0 has been installed into hosted agent successfully.
Just one thing you should pay attention to, after the pipeline finished, our server will recycle the image of the currently used host agent. And the system will obtain a brand new agent image when you re-run the pipeline. So, this powershell task must be executed in every pipeline to let the environment satisfied your requirements.

Azure Cloud Shell Ansible with Windows hosts

Since the announcement I'm able to list my Azure infrastructure in the Azure Cloud Shell with ansible.
I want to use it with Windows machines too. I installed the winrm locally as it seems that globally is not supported.
pip install "pywinrm>=0.2.2" --user
With this I understand packages are correctly installed
pywinrm (0.3.0)
requests (2.18.4)
xmltodict (0.11.0)
...
Then I run, with the proper credentials a win ping but ansible complains that the WinRM is not available.
ansible -i workspace/azure_rm.py -m win_ping DC-01
Is it possible to run ansible in cloud shell with windows hosts?
Make sure your windows hosts are setup for WinRM control. That means you should check off a few things are working, you can see what Ansible has to say about it here.
Network path is open on TCP port 5985-5986 (try to telnet)
Powershell 3.0 or above is installed
WinRM remoting has been configured for the remote windows host.
Make sure the ansible play is using WinRM port to connect
You can use the excellent PS script ansible provides with a little modification if needed to setup your local certs and configure the box from here.
I finally opened a post on MSDN forums and Microsoft identified the missing dependency and added in the Cloud Shell!
Finally it is possible to use Ansible from the Cloud Shell. The only consideration is that the target VM should have internet connectivity on port 5986.
Also there is a sample script to test it.

Resources