This file contains hidden or 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
| $filteredPolicies = New-Object System.Collections.ArrayList | |
| $policies = Get-AzResource -ResourceType "Microsoft.Network/networkIntentPolicies" | |
| foreach ($policy in $policies) { | |
| $Id = $policy.ResourceId | |
| $response = Invoke-AzRestMethod -Method "GET" -Uri "https://management.azure.com$($Id)?api-version=2021-02-01" | |
| $responseObj = $response.Content | ConvertFrom-Json | |
| $policyInfo = [PSCustomObject]@{ Id = $responseObj.id; Subnet = ""; Orphaned = $false; } | |
| if ($responseObj.properties.PSObject.Properties.Match("subnets").Count -gt 0) { |
This file contains hidden or 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
| Param( | |
| [Parameter(Mandatory=$false)] | |
| [string]$subscriptionID = "YourSubscriptionIDHere", | |
| [Parameter(Mandatory=$false)] | |
| [ValidateSet("suspend", "resume")] | |
| [string]$operation = "suspend", | |
| [Parameter(Mandatory=$false)] | |
| [string]$suspendAPIVersion = "api-version=2023-11-01" |
This file contains hidden or 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
| select | |
| db_name(database_id) as database_name, | |
| [size_in_MiB] = CAST([size] * 8 / 1024.0 AS DECIMAL(10,2)), | |
| CASE | |
| WHEN CAST([size] * 8 / 1024.0 AS DECIMAL(10,2)) <= 132096 THEN 500 -- If less than or equal to 129 GiB | |
| WHEN CAST([size] * 8 / 1024.0 AS DECIMAL(10,2)) > 132096 AND CAST([size] * 8 / 1024.0 AS DECIMAL(10,2)) <= 525312 THEN 2300 -- If more than 129 GiB but less than or equal to 513 GiB | |
| WHEN CAST([size] * 8 / 1024.0 AS DECIMAL(10,2)) > 525312 AND CAST([size] * 8 / 1024.0 AS DECIMAL(10,2)) <= 1049600 THEN 5000 -- if more than 513 GiB but less than 1025 GiB | |
| ELSE 7500 -- Any more than 1025 GiB and you get 7500 | |
| END as file_iops | |
| from sys.master_files |
This file contains hidden or 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
| CREATE EVENT SESSION [FailedQueries] ON SERVER | |
| ADD EVENT sqlserver.error_reported | |
| (ACTION(sqlserver.client_app_name, sqlserver.client_hostname, | |
| sqlserver.database_name, sqlserver.sql_text, sqlserver.username) | |
| WHERE ([package0].[greater_than_int64]([severity], (10)) AND client_app_name='SQLExternalMonitoring')) | |
| WITH (STARTUP_STATE = ON) | |
| GO |
This file contains hidden or 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
| resources | |
| | where type == "microsoft.sql/servers/databases" or type == "microsoft.sql/managedinstances" or type == "microsoft.sql/servers/elasticpools" | |
| | where properties.licenseType == "LicenseIncluded" | |
| | extend SqlEdition = case(sku.name hasprefix_cs "GP_", "Standard", sku.name hasprefix_cs "HS_", "Standard", sku.name hasprefix_cs "BC_", "Enterprise", "Unknown") | |
| | extend vCores = toint(sku.capacity) | |
| | extend licensesNeeded = toint(round(vCores/2)) | |
| | project licensesNeeded, vCores, SqlEdition | |
| | summarize sum(licensesNeeded) by SqlEdition |
This file contains hidden or 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
| $allRecommendations = New-Object -TypeName "System.Collections.ArrayList" | |
| Get-AzSubscription | ForEach-Object { | |
| $sub = $_ | |
| Set-AzContext -SubscriptionId $_.Id | |
| $recommendations = Get-AzSqlServer | Get-AzSqlDatabase | Where-Object Edition -ne "System" | Get-AzSqlDatabaseSensitivityRecommendation | |
| $recommendations | ForEach-Object { | |
| $dbinfo = $_ | |
| $_.SensitivityLabels | ForEach-Object { | |
| $newRecommandation = $_ | Select-Object @{label = 'SubscriptionId'; expression = {$sub.Id}}, @{label = 'ResourceGroupName'; expression = {$dbinfo.ResourceGroupName}}, @{label = 'ServerName'; expression = {$dbinfo.ServerName}}, @{label = 'DatabaseName'; expression = {$dbinfo.DatabaseName}}, * | |
| $allRecommendations.Add($newRecommandation) |
This file contains hidden or 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
| resources | |
| | where type == "microsoft.hybridcompute/machines" | |
| | where properties.osName == "windows" | |
| | extend joinId = tolower(id) | |
| | join kind = leftouter ( | |
| resources | |
| | where type == "microsoft.azurearcdata/sqlserverinstances" | |
| | extend arcMachineId = tolower(tostring(properties.containerResourceId)) | |
| | extend sqlVersion = tostring(properties.version) | |
| | extend vCores = toint(properties.vCore) |
This file contains hidden or 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
| { | |
| "contentVersion": "1.0.0.0", | |
| "parameters": { | |
| "workbookDisplayName": { | |
| "type": "string", | |
| "defaultValue": "SQL Licensing Summary", | |
| "metadata": { | |
| "description": "The friendly name for the workbook that is used in the Gallery or Saved List. This name must be unique within a resource group." | |
| } | |
| }, |
This file contains hidden or 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
| # Run this first via Cloud Shell to create your Service Principal and get all the needed information | |
| $sp = New-AzADServicePrincipal -DisplayName "Arc-for-servers" -Role "Owner" | |
| $tenantId= (Get-AzContext).Tenant.Id | |
| $sp.AppId | |
| $sp.PasswordCredentials.SecretText | |
| $tenantId | |
| # Run this locally after all permissions have been set. | |
| $servicePrincipalAppId="Value of $sp.AddId" |
This file contains hidden or 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
| # Need two parameters when called, the input CSV list of all servers and the Output folder | |
| # CSV File must be structured like below (Note ServerName,InstanceName header must be included) | |
| # ServerName,InstanceName | |
| # localhost,MSSQLSERVER | |
| param($CsvPath, $OutFolder) | |
| mkdir -p "$OutFolder\SqlAssessments" |
NewerOlder