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
| $runAsElevated =($PSVersionTable.OS -match "Windows" -and [bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544")) -or | |
| ($PSVersionTable.OS -match "Linux" -and $EUID -eq 0); | |
| if($runAsElevated){ | |
| $ProfileFile = $($PROFILE | Select-Object AllUsersAllHosts).AllusersAllHosts; | |
| }else{ | |
| $ProfileFile = $($PROFILE | Select-Object CurrentUserAllHosts).CurrentUserAllHosts; | |
| } | |
| $ProfilePath = $ProfileFile.Substring(0, $ProfileFile.LastIndexOf("\") + 1); | |
| $FileExists = [System.IO.File]::Exists($ProfileFile); |
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
| #Author: Gustavo Américo | |
| #Repository: https://gist.github.com/GustavoAmerico | |
| function Git-Update-All-BranchsFromBase { | |
| #Esse script é responsável por executar um merge automático de uma branch base para todas as outras branchs. Em caso de conflitos o script faz rollback e pula a branch conflitante | |
| param([Parameter(Mandatory = $true)][String]$branchNamePattern, $remoteName = 'origin', $branchBase = 'master') | |
| $branchsToUpdate = (git branch --all | % { $_.ToString().Replace("remotes/$remoteName/", '').Trim() } | Select-String -Pattern $branchNamePattern); | |
| $branchsToUpdate | % { | |
| git checkout $_; | |
| git pull --all; |
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
| function Get-PublicIPV6 { | |
| #This function return the public IP of the machine | |
| #It is used to register the IP on Azure SQL Server firewall rules | |
| try { | |
| $mypublicip = (Invoke-WebRequest https://v6.api.ipinfo.io/ip | Select-Object -Property Content).Content.Trim(); | |
| } | |
| catch { | |
| } | |
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
| function k8s-certificates-renew { | |
| param([Parameter()][int]$days = 15) | |
| ((kubectl get certificates -A -o json | ConvertFrom-Json).items) | | |
| ? { [Datetime]($_.status.renewalTime) -lt (Get-Date).AddDays($days) } | | |
| % { [pscustomobject]@{Name = $_.metadata.name; RenewAt = [DateTime]$_.status.renewalTime; Namespace = $_.metadata. Namespace } } | |
| } | |
| function k8s-Select-Resources { |
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 PROCEDURE dbo.PROC_AddOrUpdateTableAndColumnDescription | |
| @fullName varchar(255), | |
| @description varchar(255) | |
| AS | |
| /* | |
| Table exemple: <schema>.<table name> dbo.MyTable | |
| Column Exemple: <schema>.<table name>.<column name> dbo.MyTable.Id | |
| */ | |
| /*Extrai o primeiro valor antes do ponto, representa o schema*/ |
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
| #Esse script pode ser utilizado em tarefa do AzureDevOps para executar o backup da base de dados dentro do processo de Build ou Release | |
| param( | |
| $BaseStorageUri = "https://<your-storage>.blob.core.windows.net/backup-database", | |
| $StorageKey = "<Shared key>", | |
| $DatabaseName = @( "db1","db2","db3"), | |
| $ResourceGroupName = "<database-resource-group-name>", | |
| $ServerName = "<database-server-name>", | |
| $serverAdmin = "<database-user-with-permission-login>", | |
| $serverPassword = "<database-user-with-permission-password>" |