I am trying to install the latest Azure PowerShell (released Nov. 9th 2015). If I try to install it using Web Platform Installer, I get the following error:
Azure Modules from the PowerShell Gallery are installed on this machine. Please remove these modules before installing this MSI.
If I run Get-InstalledModule in PowerShell, I see that the Module Azure (version 0.9.11) is installed. So I tried uninstalling it using the PowerShell command Uninstall-Module Azure. Here I get the following error:
PackageManagement\Uninstall-Package : The property 'ModuleBase' cannot be found on this object. Verify that the
property exists.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\PSGet.psm1:1351 char:21
+ ... $null = PackageManagement\Uninstall-Package #PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Microsoft.Power...ninstallPackage:UninstallPackage) [Uninstall-Package],
Exception
+ FullyQualifiedErrorId : PropertyNotFoundStrict,Microsoft.PowerShell.PackageManagement.Cmdlets.UninstallPackage
Ok, I solved my problem. Stupid mistake: I was not running Uninstall-Module Azure as an admin. Once I started PowerShell with admin priviledges, uninstalling old Azure PowerShell was no problem.
Hm, would love to see a more descriptive error message in that case ;-)
I hit the same issue, but did not have anything Azure related appear when I executed Get-InstalledModule.
If you execute $env:PSModulePath in a powershell prompt it will list out all of your Module path locations, navigate to each of those and delete anything azure related and you should be able to install the new azure powershell cmdlets.
Related
I have installed PowerShell 7 and installed module PnP.PowerShell, when i tab the commands, it is working [Get-Help of the cmdlet (Get-PnPGroupMember) provides the required output], but when i run the script getting following error not sure.
Failed;https://abc.sharepoint.com/sites/somesite;The 'Get-PnPGroupMember' command was found in the module 'PnP.PowerShell'
Not sure, where and what i am missing ?
After uninstalling Microsoft.Online.SharePoint.PowerShell module and re-installation PnP.PowerShell solved the issue, may the issue is because of having old verision of SharePoint online cmdlets caused the issue.
I want to connect to Office365 environment using modern auth, hence I will have to use Graph API services.
I had installed powershell modules required for same. And in my Windows Powershell ISE Connect-Graph is available via intellisense which means the modules got installed successfully.
However when I am running the command Connect-Graph it results into error :
Connect-Graph : Could not load file or assembly 'System.Net.Http, Version=4.1.1.2,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system
cannot find the file specified.
At line:1 char:1
+ Connect-Graph
+ ~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-Graph], FileNotFoundException
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.Graph.PowerShell.Aut
hentication.Cmdlets.ConnectGraph
It looks like it wants the files of System.Net.Http with version 4.1.1.2 which it cannot find. I am just guessing the error.
And when I run this command Add-Type -AssemblyName System.Net.Http it runs succesfully which means the files are present maybe not the correct version, However I cannot find the current version of assembly to validate that.
Any help on this is appreciated.
Since I also have ps 5.1 and have no issues running connect-graph, I can only assume that you may not have the correct .net framework versions installed. Make sure you have the proper .net framework versions installed, maybe try to install the latest 4.8 framework. since I have that installed.
Trying to set up my VSTS windows build agent to accommodate for powershell steps within VSTS but having some problems. Initially it reported that the AzurePS system capability was not present, so I made sure to install the latest Azure modules via the powershell gallery. Now, the AzurePS capability is present but certain powershell commands do not seem to work.
This may not be related to VSTS at all but rather just a configuration issue with my specific powershell installation / configuration. The full error is as follows:
The term 'Select-AzureRMSubscription' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
This error can be seen both in the VSTS release logs of the particular definition I am trying to execute, as well as when attempting to run the Select-AzureRMSubscription command directly on the box itself.
According to This MS Docs for Get-AzSubscription it's located in the module Az.Accounts.
So I had to run:
Install-module Az -AllowClobber -Force
Import-module Az
to make the command avaliable to me.
For me, updating the AzureRM module did the trick:
Update-Module -Name AzureRM
Depending on your system, you may get some messages while installing
Powershell requires NuGet provider version '2.8.5.201' or newer to
interact with NuGet-based repositories. The NuGet provider must be
available in 'C:\Program Files\PackageManagement\ProviderAssemblies'
or
'C:\Users\<...>\AppData\Local\PackageManagement\ProviderAssemblies'.
You can also install the NuGet provider by running
Install-PackagePovider -Name NuGet -MinimumVersion 2.8.5.201 -Force'.
Do you want PowerShellGet to install and import the NuGet provider
now?
[Yes] {No] [Suspend]
Choose "Yes"
You are installling the modules form an untrusted repository. If you
trust this repository, change its installationPolicy value by running
the Set-PSRepository cmdlet. Are you sure you want to install the
modules from 'PSGallery'?
[Yes] [Yes to All] [No] [No to All] [Suspend]
Choose "Yes to all"
Up to three modules will be installed/updated and directly after that, the Select-AzureRmSubscription should work immediately.
Select-AzureRmSubscription b0cabaca-1234-1337-abcd-bebedada1337
# note: this subscription GUID is completely fictional.
# To get the correct one, query your subscriptions with
# Get-AzureRmSubscription
You have to make sure that certain Azure Powershell modules are installed for certain cmdlets to work. You can check which modules are available by running Get-Module -ListAvailable. Select-AzureRMSubscription requires AzureRM module.
You could just install Azure Powershell with its modules using webPI - I've never had problems using it and I've heard that installing PS modules using gallery could cause problems (see here).
You can run azure PowerShell with Azure PowerShell step/task.
Edit your build definition
Click Add build step
Select Deploy catalog > Add Azure PowerShell step/task
the OS in question is server 2012
To install PowerShell on windows server 2012, we should add the .NET Framework 3.5 feature and add the windows PowerShell 2.0 Engine feature.
About how to add features, refer to the link.
Then we can download PowerShell installation package, and install it.
Then we can use windows server 2012 PowerShell to login azure.
You need to use the Set-AzContext,
Select-AzSubscription -SubscriptionName 'SubName' | Set-AzContext
I try to configure TFS for Continuous Delivery to Azure by this article
In article TFS published package to Azure with Powershell script.
When build starts I get errors like ObjectNotFound: (Set-AzureDeployment:String) [], CommandNotFoundException. Looks like I didn't install Azure cmdlets, but I install all from Web Platform Installer.
And when I try to run script locally on server - it works and deploys package.
In article Powershell starts by adding InvokeProcess to template with Filename="PowerShell".
I think I just don't run Powreshell correctly.
Maybe somebody has some ideas which command should I use?
Find a solution
Powershell cann't find Azure module.
Add this before Import-Module Azure command in script
$env:PSModulePath=$env:PSModulePath+";"+"C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell"
Could be that you installed the cmdlets on the user profile. Try re-install after logging in with the account running the build service.
on a windows server 2008 r2 sp1 machine, i used chocolatey to install the AWSTools.Powershell package. this, in turn, installed powershell 3. now, powershell is hopelessly broken and i can't figure out any way of fixing it or uninstalling and reinstalling it.
i fear my only answer is completely rebuilding the machine, but wanted to ask if there's a way to fix it.
powershell actually runs, it just seems it can't find any of the build-in cmdlets. it seems it does find aliases, but can't execute what's under them. for example, issuing an ls to look at directory contents yields:
PS C:\Users\Administrator> ls
ls : The term 'Get-ChildItem' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ ls
+ ~~
+ CategoryInfo : ObjectNotFound: (Get-ChildItem:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
it may be that there's just some execution of some script missing at the start that sets up the environment. if you know more than me and can offer some assistance and can make it so that i don't have to rebuild this machine, i would be very happy.
A little bit late to the game, but recently ran into this problem. I found that my PSModulePath did not include an important path. You can view your PSModulePath by running this command:
$env:PSModulePath
To add the needed path you can run this command:
$env:PSModulePath = $env:PSModulePath + ";C:\Windows\system32\WindowsPowerShell\v1.0\Modules\"
This is a very old thread, but since I found it whilst troubleshooting the exact same issue - I thought I'd mention how I resolved it.
First the problem as I experienced it:
I had PowerShell 2.0 on Windows 7, then used choco to install/upgrade to PowerShell 4.0:
choco upgrade powershell
That updated my system to 4.0, but when I opened PowerShell, the upgrade broke most of the basic cmdlets such as Get-ChildItem (aka dir).
After fumbling about online for a while, I thought I'd reinstall from the MS Website... but first I uninstalled from choco.
choco uninstall powershell
And since it was choco that broke it to begin with I thought I'd give it one more try to install cleanly with the following command:
choco install powershell --force
And low, that fixed the problem.
So I stopped there.
Hopefully that's helpful to someone.
Good luck!