我写了一个Powershell Sripct,它将我们的RG组从Azure导出到CSV文件。 这项工作在我的本地管理PC上->导出到c:\ temp \ rg.csv
如何直接通过Runbook从Azure将此列表导出到在线共享点?
# $file = "C:\temp\ResourceGroupList.csv"
$file = "https://xxx.sharepoint.com/sites/1810023/Shared%20Documents/Forms/AllItems.aspx"
$getRmResourceGroups = @()
$getRmResourceGroups += Get-AzureRmResourceGroup
if (!$getRmResourceGroups) {
Write-Output "===>>> No resource groups found."
Exit
} else {
$ExportInfo = @()
foreach ($rg in $getRmResourceGroups) {
$rgTagITProductValue = $rg.Tags.ITProduct
$rgTagCostCenterValue = $rg.Tags.CostCenter
$rgTagOpLevelValue = $rg.Tags.OpLevel
$rgTagOpHoursValue = $rg.Tags.OpHours
$rgTagDescriptionValue = $rg.Tags.RG_Description
if($rgTagDescriptionValue -cnotmatch "do not use")
{
# write-Output "Resource Group" $rg.ResourceGroupName
# Write-Output "IT Product" $rgTagITProductValue
# Write-Output "Costcenter" $rgTagCostCenterValue
$ExportInfoObject = [pscustomobject]@{
'ResourceGroupName' = $rg.ResourceGroupName
'Description' = $rgTagDescriptionValue
'ITProduct' = $rgTagITProductValue
# 'OpLevel' =$rgTagOpLevelValue
# 'OpHours' =$rgTagOpHoursValue
}
$ExportInfo += $ExportInfoObject
}
}
}
$ExportInfo | Export-Csv -NoTypeInformation -Path $file