Error when executing Get-AzureStorageAccount in azure powershell - powershell

Here is the error
PS C:\Windows\system32> Get-AzureStorageAccount
Get-AzureStorageAccount : Value cannot be null.
Parameter name: resource
At line:1 char:1
+ Get-AzureStorageAccount
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-AzureStorageAccount], AadAuthenticationFailedException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Utilities.Common.Authentication.AadAuthenticationFailedException,Microsoft.WindowsAzure.Commands.ServiceManagement.StorageServices.GetAzureStorageAccountCommand
I am getting the same error on
Get-AzureLocation,
Get-AzureWebsite
I have imported my settings file and Get-AzureSubscription works just fine and provides me all the correct information.

This solved my issue, got this from Microsoft support forum.
As far as my research goes on this, the issue can be related to cache of some account. If just adding does not work, I suggest that you remove and add the subscription again:
This article will give you information on this:
http://msdn.microsoft.com/en-us/library/dn495268.aspx

Related

Grant-CsTeamsAppPermissionPolicy not working in microsoft teams powershell

I am trying to apply permission policy to a user via powershell but it is not working
PS C:\Users\PO30261> Grant-CsTeamsAppPermissionPolicy -PolicyName "HR App Policy" -Identity d72f6b50-ac75-470a-80b8-919ab8b3232e
Get-CsOnlineSession : Connecting to remote server api.interfaces.records.teams.microsoft.com failed with the following error message : The WinRM client cannot process the request. Basic
authentication is currently disabled in the client configuration. Change the client configuration and try the request again. For more information, see the about_Remote_Troubleshooting Help
topic.
At C:\Program Files\WindowsPowerShell\Modules\MicrosoftTeams\2.3.1\net472\SfBORemotePowershellModule.psm1:63 char:22
$remoteSession = & (Get-CsOnlineSessionCommand)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : NotSpecified: (:) [Get-CsOnlineSession], PSRemotingTransportException
FullyQualifiedErrorId : PSRemotingTransportException,Microsoft.Teams.ConfigApi.Cmdlets.GetCsOnlineSession
Invoke-Command : Cannot validate argument on parameter 'Session'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
At C:\Program Files\WindowsPowerShell\Modules\MicrosoftTeams\2.3.1\net472\SfBORemotePowershellModule.psm1:19581 char:38
... -Session (Get-PSImplicitRemotingSession -CommandName 'Grant-CsTeam ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : InvalidData: (:) [Invoke-Command], ParentContainsErrorRecordException
FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeCommandCommand
Error shows that issue is not related to apply policy. Issue is with connecting to server "Basic authentication is currently disabled in the client configuration" so update module and try again. Update-Module MicrosoftTeams
Seems like a problem with powerShell version. Look at this discussion where community are following this issue, including me:
https://techcommunity.microsoft.com/t5/teams-developer/authenticating-with-an-access-token-connect-microsoftteams/m-p/2233794

I have a problem with "Create an Azure AD App" Specifically with the powershell Script "Create-AADIdentityApp.ps1"

I have installed Azure stack development kit and i am trying to install the App service.
Then when i have to run the PS1 script Create-AADIdentityApp.ps1 i fill in the following parameters
DirectoryTenantName
AdminArmEndpoint
TenantArmEndpoint
CertificateFilePath
Then i get the following error
New-Object : Exception calling ".ctor" with "3" argument(s): "The system cannot find the file specified.
"
At C:\app-service-certificate-install\Create-AADIdentityApp.ps1:81 char:24
+ ... rtificate = New-Object System.Security.Cryptography.X509Certificates. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
does anyone have any experience?
You provided a invalid CertificateFilePath.
It should be Full path to the identity application certificate file generated earlier.
Please check and correct it.

Set-PnPSite -LogoFilePath throws error? Which version of SharePointPnPPowerShellOnline required? Mine is 3.20.2004.0

Which version of SharePointPnPPowerShellOnline does support below command? Mine is 3.20.2004.0 and trying to update Modern teamsite in sharepoint online environment.
Set-PnPSite -LogoFilePath c:\images\mylogo.png
Set-Variable : A parameter cannot be found that matches parameter name 'LogoFilePath'.
At line:1 char:13
+ set pnpsite -LogoFilePath C:\Project\Images\FPASiteLogo.png
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-Variable], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.SetVariableCommand
Tested the same version PnP PowerShell which is the latest version and LogoFilePath parameter is available, please see the PowerShell snippet:
But the site needs to be a Moder Site:
Reference:
Set-PnPSite

Unable to Use Windows Update COM object in RemotePS sessions

Im trying to change the windows update settings in a remote server using powershell, but when i run the below commands it gives me an error.
PS C:\Windows\system32> Enter-PSSession opalisbinary
[opalisbinary]: PS C:\Users\superv\Documents> $AUSettings = (New-Object -com "Microsoft.Update.AutoUpdate").Settings
[opalisbinary]: PS C:\Users\superv\Documents> $AUSettings.NotificationLevel=2
Property 'NotificationLevel' cannot be found on this object; make sure it exists and is settable.
At line:1 char:14
+ $AUSettings. <<<< NotificationLevel=2
+ CategoryInfo : InvalidOperation: (NotificationLevel:String) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
[opalisbinary]: PS C:\Users\superv\Documents> $AUSettings.IncludeRecommendedUpdates=$true
Property 'IncludeRecommendedUpdates' cannot be found on this object; make sure it exists and is settable.
At line:1 char:14
+ $AUSettings. <<<< IncludeRecommendedUpdates=$true
+ CategoryInfo : InvalidOperation: (IncludeRecommendedUpdates:String) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
[opalisbinary]: PS C:\Users\superv\Documents> $AUSettings.Save()
You cannot call a method on a null-valued expression.
At line:1 char:18
+ $AUSettings.Save <<<< ()
+ CategoryInfo : InvalidOperation: (Save:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Although when i run it locally on the server it works fine...
Could anyone please help me.
Does it work when you connect via Remote desktop and run the commands? It also depends on the bittnes. I don't know the Microsoft.Update.AutoUpdate, so I'm just guessing, but - is it available for x64 version of PowerShell? In other words if you run it locally in x64 version and x86, do you see the errors?
I am sorry, I could not find a real answer. What I found is this link which states that remote PS sessions can be used with SCCM 2012, but they could not with SCCM 2007.
This does not help you, but it seems that not all COM objects are compatible with remote PS sessions.

How can I run an Azure powershell cmdlet through a proxy server with credentials?

When I run the following Powershell cmdlet (from the Azure Management Tools Snapin):
get-osversions -subscriptionId **** -certificate (get-item cert:\CurrentUser\MY\******)
I get the following error message:
Get-OSVersions : The remote server returned an unexpected response: (407) Proxy Authenti
cation Required.
At line:1 char:15
+ get-osversions <<<< -subscriptionId * -certificate
(get-item cert:\CurrentUser\MY*****)
+ CategoryInfo : CloseError: (:) [Get-OSVersions], ProtocolException
+ FullyQualifiedErrorId : Microsoft.Samples.AzureManagementTools.PowerShell.HostedS
ervices.GetOSVersionsCommand
Get-OSVersions : Object reference not set to an instance of an object.
At line:1 char:15
+ get-osversions <<<< -subscriptionId * -certificate
(get-item cert:\CurrentUser\MY***)
+ CategoryInfo : CloseError: (:) [Get-OSVersions], NullReferenceException
+ FullyQualifiedErrorId : Microsoft.Samples.AzureManagementTools.PowerShell.HostedS
ervices.GetOSVersionsCommand
It seems that the internet proxy server here is denying the script the access it requires.
I've had a good look around on the internet and it seems that there is no easy way around this problem since this cmdlet does not have a valid "-credentials" or proxy server parameter.
I know there is a 'Get-Credential' cmdlet but I don't think it helps. How would you pass the credential to the Azure cmdlet?
Can anyone think of any way to get around this issue?..
...other than using a different non-proxied internet connection?
I'm stumped.
Many Thanks for your time.
Easier:
[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
A few customers I know were successful using the method outlined here (Supporting Basic Auth proxies). If you need other proxy types, it follows the same pattern. The nice thing about this is it does not require changing the cmdlets.