update
This commit is contained in:
92
Microsoft Azure/Azure-Migrate-Test.ps1
Normal file
92
Microsoft Azure/Azure-Migrate-Test.ps1
Normal file
@ -0,0 +1,92 @@
|
||||
[CmdletBinding()]
|
||||
|
||||
param (
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
|
||||
[string]
|
||||
|
||||
$SubsID,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
|
||||
[string]
|
||||
|
||||
$FilePath = "$Env:USERPROFILE\Desktop\AzureMoveResourcesReport.docx"
|
||||
|
||||
)
|
||||
|
||||
Import-Module Az
|
||||
Import-Module PSWriteWord
|
||||
|
||||
|
||||
if ($SubsID) {
|
||||
|
||||
Connect-AzAccount -Subscription $SubsID | Out-Null
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
Connect-AzAccount | Out-Null
|
||||
|
||||
}
|
||||
|
||||
$WordDocument = New-WordDocument $FilePath
|
||||
|
||||
#$res = Invoke-WebRequest -Uri https://raw.githubusercontent.com/tfitzmac/resource-capabilities/master/move-support-resources.csv -Method Get
|
||||
#$list = Convertfrom-csv -InputObject $res.Content
|
||||
|
||||
$list = Import-Csv -Path "move-support-resources.csv"
|
||||
|
||||
$resGroups = Get-AzResourceGroup
|
||||
|
||||
foreach ($group in $resGroups) {
|
||||
|
||||
$resObjs = Get-AzResource -ResourceGroupName $group.ResourceGroupName
|
||||
|
||||
Add-WordText -WordDocument $WordDocument -Text "`nResources Group: $($group.ResourceGroupName)" -FontSize 20 -Color Blue -Supress $True
|
||||
Add-WordLine -WordDocument $WordDocument -LineColor Blue -LineType double -Supress $True
|
||||
|
||||
foreach ($obj in $resObjs) {
|
||||
|
||||
$resName = $obj.Name
|
||||
|
||||
$resType = $obj.ResourceType
|
||||
|
||||
$resID = $obj.ResourceId
|
||||
|
||||
$resList = $list -match $obj.ResourceType
|
||||
|
||||
if ($resList) {
|
||||
|
||||
$i = [int]$resList[0].'Move Subscription'
|
||||
|
||||
if ($i -ne 1) {
|
||||
|
||||
Write-Host "`nOBJECT CAN _NOT_ BE MIGRATED: $resName has type $resType ($resID)" -ForegroundColor Yellow -BackgroundColor DarkRed
|
||||
Add-WordText -WordDocument $WordDocument -Text "`nOBJECT CAN _NOT_ BE MIGRATED: $resName has type $resType ($resID)" -FontSize 12 -Color Red -Supress $True
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
Write-Host "`nOBJECT SUPPORTED FOR MIGRATION: $resName has type $resType ($resID)" -ForegroundColor Green
|
||||
Add-WordText -WordDocument $WordDocument -Text "`nOBJECT SUPPORTED FOR MIGRATION: $resName has type $resType ($resID)" -FontSize 12 -Color Green -Supress $True
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
Write-Host "UNKNOWN OBJECT's TYPE: $resName has type $resType ($resID)" -ForegroundColor DarkRed -BackgroundColor Yellow
|
||||
Add-WordText -WordDocument $WordDocument -Text "UNKNOWN OBJECT's TYPE: $resName has type $resType ($resID)" -FontSize 12 -Color Yellow -Supress $True
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Save-WordDocument $WordDocument -Language 'en-US' -Supress $True -OpenDocument:$true
|
30
Microsoft Azure/Get-Storagelength.ps1
Normal file
30
Microsoft Azure/Get-Storagelength.ps1
Normal file
@ -0,0 +1,30 @@
|
||||
#Reprise d'un exemple officiel pour calculer la taile d'un conteneur Blob sur Azure
|
||||
#Attention les opérations de lecture sont facturables !
|
||||
|
||||
# these are for the storage account to be used
|
||||
$resourceGroup = ""
|
||||
$storageAccountName = ""
|
||||
$containerName = ""
|
||||
|
||||
# get a reference to the storage account and the context
|
||||
$storageAccount = Get-AzStorageAccount `
|
||||
-ResourceGroupName $resourceGroup `
|
||||
-Name $storageAccountName
|
||||
$ctx = $storageAccount.Context
|
||||
|
||||
# get a list of all of the blobs in the container
|
||||
$listOfBLobs = Get-AzStorageBlob -Container $ContainerName -Context $ctx
|
||||
|
||||
# zero out our total
|
||||
$length = 0
|
||||
|
||||
# this loops through the list of blobs and retrieves the length for each blob
|
||||
# and adds it to the total
|
||||
$listOfBlobs | ForEach-Object { $length = $length + $_.Length }
|
||||
|
||||
# output the blobs and their sizes and the total
|
||||
Write-Host "List of Blobs and their size (length)"
|
||||
Write-Host " "
|
||||
$listOfBlobs | select Name, Length
|
||||
Write-Host " "
|
||||
Write-Host "Total Length = " $length
|
1
Microsoft Azure/README.md
Normal file
1
Microsoft Azure/README.md
Normal file
@ -0,0 +1 @@
|
||||
# Microsoft Azure
|
Reference in New Issue
Block a user