I made a system that every morning, I get CSV files using AzurePopwershell from Azure
for example
select-azuresubscription -SubscriptionName "Kazu Pay-As-You-Go"
Get-AzureVM | export-csv -Path "C:\Users\kazu\Desktop\AzureProject\kazu-Pay-As-You-Go-VM.csv"-NoTypeInformation
This morning, My boss just told me That our company only getting information of two of directories/accounts from Azure. My company has three directories/accounts. so, we clicked on "Subscriptions" on left top on https://manage.windowsazure.com/--->"FILTER BY DIRECTORY:", There are 3 directories/account, he told me we are getting information from directories/account from only "mycompany3" and "mycompany1" , he also wants me to get information from "mycompany2".
so I clicked "directory3" and it shows under "FILTER BY SUBSCRIPTIONS:"
Select ALL
3-month Free trial
kazu Pay-As-You-Go
I clicked "directory1" and it shows under "FILTER BY SUBSCRIPTIONS:"
Select ALL
Pay-As-You-Go
I clicked "directory2" and it shows under "FILTER BY SUBSCRIPTIONS:"
Select ALL
Main Subscription
SO I went AzurePowershell and did
Get-AzureSubscription
echo was
3-month Free trial
Pay-As-You-Go
kazu Pay-As-You-Go
I noticed that "Main Subscription" is missing
At first, when I started to do project, I followed http://blogs.technet.com/b/canitpro/archive/2013/11/06/set-by-step-manage-windows-azure-using-powershell.aspx
How can I connect to "directory2" , "Main Subcription"?
How did you authenticate with Azure Powershell? By using Add-AzureAccount, or by using Import-AzurePublishSettingsFile? If you used the publish settings file, you might not have had the other subscription in there. Try using Add-AzureAccount, which should mimic the same permission set as when you are logged in.
Related
I would like to retrieve the following attributes: "createdDateTime, extension_xxxxxx_yyyyy, identities" from AD B2C users. With Graph Explorer, I could do this with:
https://graph.microsoft.com/v1.0/users?$select=createdDateTime extension_xxxxxx_yyyyy, identities
Then, I tried the snippet generated by Graph Explorer for PowerShell
Get-MgUser -Property “createdDateTime,+ extension_xxxxxx_yyyyy,identities”
I got the following error:
Parsing OData Select and Expand failed: Syntax error: character '+' is
not valid at position 17 in 'createdDateTime, +exten ……
I removed the “+” and retried, it had no error, but all the returned fields were blank.
I am using Microsoft Graph PowerShell SDK 1.18
It is easier to use the beta version of the API
Select-MgProfile -Name "beta"
CreatedDateTime can be got directly
Identities can be got directly but it is an array
extension_xxxxxx_yyyyy is the trickiest, it is packed inside the AdditionalProperties
So, I have the resource Group name and i want to programmatically (using powershell) set the subscription to the incoming resource group.
When i do a Get-AzResourceGroup I get the ResourceId which contains the the subscription id as part of a long string /subscriptions/<subscription id here>/resourceGroups/resourcegroupname. Is there a way to extract the subscription Id from that string?
You can get your subscription ID by triggering the below. You will also need to have azure cli installed.
az account list --refresh --query "[?contains(name, 'YOUR_SUBSCRIPTION')].id"
You can also split the output from powershell.
$myinput= "/subscriptions/xxxxxx-xxxxxx-xxxxxx-xxxxx-xxxxxx/resourceGroups/resourcegroupname".Split("/")
Write-Host $myinput[2]
I had created 3 buckets for testing and then later on deleted via PowerShell Command as below:
Get-S3Bucket| select -Skip 1 | foreach {Remove-S3Bucket -BucketName $_.Bucketname -DeleteBucketContent}
However, after couple of hours, I run Get-S3Bucket and I see the same buckets listed. I checked the console and found 3 buckets already there. I tried opening one of them and got "Data Not Found" error as per this screenshot:
Link:[https://onedrive.live.com/?cid=AE48A34880F3B8E4&id=AE48A34880F3B8E4%21142505&parId=AE48A34880F3B8E4%21111&o=OneUp]
I thought it might be a stale object, so tried creating another with the same name and it won't let me create one saying 'bucket already exists', as per below screenshot:
Link:[https://onedrive.live.com/?cid=AE48A34880F3B8E4&id=AE48A34880F3B8E4%21142504&parId=AE48A34880F3B8E4%21111&o=OneUp]
I tried again removing it from PowerShell, and get this error "The specified bucket does not exist", below screenshot:
Link:[https://onedrive.live.com/?cid=AE48A34880F3B8E4&id=AE48A34880F3B8E4%21142506&parId=AE48A34880F3B8E4%21111&o=OneUp]
Can someone suggest anything?
-kt
I am trying to use get-azurermsubscription to get a list of available subscriptions in order to select one of five prior to running set-azurermcontext. I am getting the error:
Method not found: 'Microsoft.Azure.Subscriptions.Models.SubscriptionListResult'
get-azurermcontext displays a valid tenatant id and valid subscription id, but of course does not display all of the subscriptions.
I downloaded the March 2015 Powershell installer to make sure everything was up to date, but have the same issues.
Just upgraded to VisualStudio 2015 update 2 and powershell v5. Have another machine with a similar configuration that works fine.
What should I do to fix this issue?
I can't add a comment so doing it this way instead. On July 12 2016 AzureRM module received and update to version 1.6.0. I confirmed the cmd Get-AzureRMSubsctiption works from a Windows 10 machine.
I am using Visual Studio Online - Package Manager Preview, along with the new build system. The package manager preview adds a number of build steps, including a "NuGet Publisher" step, which should push packages to the private feed hosted by Visual Studio Online.
Now the documentation is a little out of step here. As is the documentation on auth and personal access tokens. There are some indications that you shouldn't need auth between VSO and the Package Manager as long as you have permissions set up (the build service account has permissions to the service endpoint and to the package manager extension). The actual build step asks you to select from your list of Service Endpoints, so that is what I have attempted.
When I place no credentials on the Service Endpoint, I get the error:
Server Key must be set, set the password on the generic service
When I attempt to place the API key against the Service Endpoint it seems to be discarded on save... and the error changes to:
2015-11-18T08:35:24.5678951Z Invoking nuget with push C:\a\1\s\EventViewer\bin\Release\Project.Name.1.1.12.0.nupkg -s https://example.pkgs.visualstudio.com/DefaultCollection/_packaging/example/nuget/v3/index.json usfusmx4ez6mlfqwpp2abzc7e37denfcp7bxsep2hqij3tp4qwvq on C:\a\1\s\EventViewer\bin\Release\Project.Name.1.1.12.0.nupkg
2015-11-18T08:35:24.5688946Z C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\default\agent\worker\tools\NuGet.exe push C:\a\1\s\EventViewer\bin\Release\Project.Name.1.1.12.0.nupkg -s https://example.pkgs.visualstudio.com/DefaultCollection/_packaging/Example/nuget/v3/index.json usfusmx4ez6mlfqwpp2abzc7e37denfcp7bxsep2hqij3tp4qwvq
2015-11-18T08:35:25.3467312Z Please provide credentials for: https://example.pkgs.visualstudio.com/DefaultCollection/_packaging/Example/nuget/v3/index.json
2015-11-18T08:35:25.3667189Z ##[error]Object reference not set to an instance of an object.
2015-11-18T08:35:25.3677179Z UserName: Password:
2015-11-18T08:35:25.4647059Z ##[error]Unexpected exit code 1 returned from tool NuGet.exe
I have also attempted to use a personal access token to no avail.
How do I get the publish step working?
The in-box NuGet Publish task has two options: "external" feeds and "internal" feeds. External feeds are intended for 3rd party services like NuGet.org, Artifactory, and expect a service connection with an API key.
Internal feeds are those hosted by Team Services. Instead of a service connection, you add the URL of the feed's NuGet endpoint. The build system relies on the Project Collection Build Service (for collection-scoped build definitions) or Project Build Service (for "this project"-scoped build defs) being a Reader or Contributor to the feed. Docs for all that are available here.
UPDATE: It is all fixed now so you can use the standard packaging steps in vNext and they work like a charm.
For the time being, I am substituting the NuGet Publisher step with a PowerShell build step.
This slots into the build after the "NuGet Packager" step and allows me to specify all of the credentials by setting up a package source before pusing the package.
$feedUrl = "https://example.pkgs.visualstudio.com/DefaultCollection/_packaging/Example/nuget/v3/index.json"
$packagePath = $ENV:BUILD_REPOSITORY_LOCALPATH + "\YourOrg.YourComponent." + $ENV:BUILD_BUILDNUMBER + ".nupkg"
Write-Host "Adding package Source"
$addSourceCommand = $ENV:BUILD_REPOSITORY_LOCALPATH + "\nuget sources add -name ""Example"" -source " + $feedUrl + " -username ""your.username"" -password ""yourpassword"""
Invoke-Expression -Command $addSourceCommand
Write-Host "Pushing package to NuGet"
$pushCommand = $ENV:BUILD_REPOSITORY_LOCALPATH + "\nuget push $packagePath -Source " + $feedUrl + " -ApiKey Example"
Invoke-Expression -Command $pushCommand
I landed here because I'm researching/configuring an internal deploy -- where I'm running my own NuGet Server (nuget.server, as opposed to visual studio online). The error was the same (or has similar text):
Object reference not set to an instance of an object
My solution, it turned out, was that the URL wasn't right.
The correct version is: http://server-name/NuGet/api/v2/package
For completeness, I had: http://server-name/NuGet/ which was wrong.