Last active
April 20, 2018 06:45
-
-
Save Agazoth/e5207bb56052cfece7eb64d13ff40b13 to your computer and use it in GitHub Desktop.
Get-CSPBilling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module PartnerCenterModule | |
Import-Module PSExcel | |
$Destination = 'C:\Billing' | |
$BillingFilename = '{0}-{1}-{2}Billing.xlsx' | |
$clientSecret = 'Your super secret string' | |
$CSPAppID = 'Your App GUID' | |
$CSPDomain = 'Your CSP Domain' | |
$clientSecretSecure = $clientSecret | ConvertTo-SecureString -AsPlainText -Force | |
Add-PCAuthentication -cspAppID $CSPAppID -cspDomain $CSPDomain -cspClientSecret $clientSecretSecure | |
$Latest = Get-PCInvoice -all | Select-Object -First 1 | |
'Azure','Office' | ForEach-Object { | |
$Params = @{ | |
invoiceid = $Latest.id | |
billingprovider = $_ | |
invoicelineitemtype = "BillingLineItems" | |
} | |
$FilePath = Join-Path $Destination $($BillingFilename -f $(Get-Date $Latest.invoiceDate -uformat "%Y-%m-%d"),$Latest.id,$_) | |
Get-PCInvoiceLineItems @Params | Export-xlsx $FilePath | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment