Open kreatd opened 4 months ago
Connect-MgGraph -Scopes "Mail.Send"
$emailParams = @{ Subject = "Test Email" Body = @{ Content = "This is a test email." ContentType = "Text" } ToRecipients = @( @{ EmailAddress = @{ Address = "recipient@example.com" } } ) }
Send-MgUserMessage -UserId "user@example.com" -Message $emailParams
$tenantId = "
$body = @{ grant_type = "client_credentials" client_id = $clientId client_secret = $clientSecret scope = $scope }
$response = Invoke-RestMethod -Method Post -Uri $authority -ContentType "application/x-www-form-urlencoded" -Body $body $accessToken = $response.access_token
$accessToken
$emailBody = @{ message = @{ subject = "Test Email" body = @{ contentType = "Text" content = "This is a test email from the Azure Government Cloud." } toRecipients = @( @{ emailAddress = @{ address = "recipient@example.com" } } ) } }
$response = Invoke-RestMethod -Method Post -Uri "https://graph.microsoft.us/v1.0/users/ -Headers @{Authorization = "Bearer $accessToken"}
-Body ($emailBody | ConvertTo-Json -Depth 3) `
-ContentType "application/json"
$response
Authenticate to Azure
Connect-AzAccount
Define your subscription ID, resource group name, and ASR vault name
$subscriptionId = "your-subscription-id" $resourceGroupName = "your-resource-group-name" $vaultName = "your-asr-vault-name"
Construct the URL for the API request to get protected items
$url = "https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.RecoveryServices/vaults/$vaultName/replicationProtectedItems?api-version=2022-03-01"
try {
Make the API request to get protected items
} catch { Write-Error "Error occurred: $($_.Exception.Message)" }