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
| # quicker method | |
| # get | |
| kubectl delete pod --all-namespaces --field-selector=status.phase=Failed | |
| # and delete | |
| kubectl delete pod --all-namespaces --field-selector=status.phase=Failed | |
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
| -- Index stats are from the last restart - this will show you the days | |
| select datediff(d,create_date,getdate()) | |
| from sys.databases | |
| where name = 'tempdb' | |
| /* | |
| You can either run this with specific schema or table names or you can run it with % in those variables to get all indexes for a schema or for the whole database | |
| @schPat SYSNAME = '%' | |
| ,@tblPat SYSNAME = '%' |
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
| use msdb | |
| select top 100 name,database_name, | |
| case type | |
| when 'D' then 'Full' | |
| when 'I' then 'Differential' | |
| when 'L' then 'Log' end as backupType, backup_start_date, backup_finish_date, DATEDIFF(MINUTE,backup_start_date,backup_finish_date) as durationMins, | |
| cast ((compressed_backup_size/1000)/1000 as int) as compressed_backup_size_MB, | |
| cast ((backup_size/1000)/1000 as int) as backup_size_mb, | |
| user_name, first_lsn, last_lsn, checkpoint_lsn, database_backup_lsn, is_copy_only |
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
| $registry='DmmPortalAcr' | |
| write-host "Getting all repos..." | |
| $repos=(az acr repository list -n $registry -o tsv) | |
| $progress=0 | |
| $total_items=$repos.Count | |
| $res = @() | |
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
| # collect data | |
| $applications = Get-AzADApplication | |
| $servicePrincipals = Get-AzADServicePrincipal | |
| # match service principals with applications | |
| $appWithCredentials = @() | |
| $appWithCredentials += $applications | Sort-Object -Property DisplayName | ForEach-Object { | |
| $application = $_ | |
| $sp = $servicePrincipals | Where-Object AppId -eq $application.AppId |
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
| |
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
| --restore history | |
| SELECT rh.restore_date,bs.backup_start_date, rh.stop_at, rh.destination_database_name, | |
| case rh.restore_type | |
| when 'D' then 'Full' | |
| when 'I' then 'Differential' | |
| when 'L' then 'Log' end as Restore_Type, bs.server_name as SourceServer, bs.database_name as SourceDB, backup_size as backupsize_bytes, (backup_size * 0.000001) as backupsize_MB | |
| FROM MSDB.DBO.restorehistory rh | |
| inner join msdb.dbo.backupset bs | |
| on rh.backup_set_id = bs.backup_set_id | |
| ORDER BY rh.restore_date DESC |
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
| <# | |
| .SYNOPSIS | |
| Function to get a list of Quarterfinal scores from CrossFit Games API for a specific affiliate | |
| .DESCRIPTION | |
| Function to get a list of Quarterfinal scores from CrossFit Games API for a specific affiliate | |
| .PARAMETER affiliateName | |
| The name of the affiliate to filter by, e.g. 'CrossFit Southampton' |
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
| ## Using PSHTML to create great looking email reports | |
| ## Blog post with more information: https://jesspomfret.com/pshtml-email-reports | |
| ## Email details | |
| $emailTo = '[email protected]' | |
| $emailFrom = '[email protected]' | |
| $emailSubject = ('Authors: {0}' -f (get-date -f yyyy-MM-dd)) | |
| $smtpServer = 'smtp.server.address' | |
| ## Query details |
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
| $perms = import-excel -Path C:\Temp\spreadsheetName.xlsx -WorksheetName permissions | |
| <# | |
| The spreadsheet should have a worksheet named permissions with the following columns: | |
| Username Server Database Permissions | |
| JessUser mssql1 database1 db_datareader | |
| UserName2 mssql2 database2 db_datareader, db_datawriter, execute | |
| #> |
NewerOlder