Advertisement
RJSN

TypeConversion

Jul 24th, 2017
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $resources = Find-AzureRmResource
  2.  
  3. Write-Verbose -Verbose "Processing information..."
  4. 'CloudType;Type' | out-file -FilePath C:\AzureTypesTMP.csv
  5. $all = foreach ($item in $resources)
  6. {
  7.   $cloudtype = $item.Name.Substring(0,7)
  8.   $types = $item.Name.Substring(4,3)
  9.    
  10. Switch ($types)
  11. {
  12.     ASE { $realtype = "Application Service Environment"; break }
  13.     API { $realtype = "API Service"; break }
  14.     ASP { $realtype = "App Service plan"; break }
  15.     CSE { $realtype = "Cognitive Services"; break }
  16.     EHB { $realtype = "Event Hub"; break }
  17.     HUB { $realtype = "Event Hub"; break }
  18.     FUA { $realtype = "Function App"; break }
  19.     LOG { $realtype = "Logic app"; break }
  20.     NSG { $realtype = "Network security group"; break }
  21.     SAJ { $realtype = "Stream Analytics job"; break }
  22.     SBU { $realtype = "Service Bus"; break }
  23.     sse { $realtype = "Search service"; break }
  24.     ssr { $realtype = "SQL server"; break }
  25.     EPD { $realtype = "SQL elastic pool"; break }
  26.     SDB { $realtype = "SQL database"; break }
  27.     EDP { $realtype = "SQL elastic pool"; break }
  28.     sta { $realtype = "Storage account"; break }
  29.     VNW { $realtype = "Virtual network"; break }
  30.     WEB { $realtype = "App Service"; break }
  31.  
  32.     Default {  "Not detected" }
  33. }
  34.    
  35.     if ($cloudtype.startswith("mscsta"))
  36.   {
  37.     $realtype = "Storage account"
  38.   }
  39.   $cloudtype + ";" + $realtype | out-file -FilePath C:\AzureTypesTMP.csv -Append
  40.  
  41. $input = 'C:\AzureTypesTMP.csv'
  42. $inputCsv = Import-Csv $input | Sort-Object * -Unique
  43. $inputCsv | Export-Csv "C:\AzureTypes.csv" -NoTypeInformation
  44. Remove-Item C:\AzureTypesTMP.csv -Force
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement