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
| $domain = '' | |
| $user = '' | |
| $oldPassword = (Read-Host 'Old Password' -AsSecureString) | |
| $newPassword = (Read-Host 'New Password' -AsSecureString) | |
| Set-ADAccountPassword -Server $domain -Identity $user -OldPassword $oldPassword -NewPassword $newPassword |
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
| Install-WindowsFeature Web-Mgmt-Service | |
| Set-Service -Name WMSVC -StartupType Automatic | |
| Start-service -Name WMSVC | |
| # download/install msdeploy from here | |
| # https://www.iis.net/downloads/microsoft/web-deploy | |
| # MAKE SURE YOU INSTALL THE "Web Deploy Handler" OPTION | |
| [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Management") | |
| $credential = Get-Credential | |
| [Microsoft.Web.Management.Server.ManagementAuthentication]::CreateUser($credential.UserName, $credential.GetNetworkCredential().Password) | |
| [Microsoft.Web.Management.Server.ManagementAuthorization]::Grant($credential.UserName, "Default Web Site", $false) |
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
| curl -X PUT -T ./{file.dat} -H "x-ms-date: $(date -u)" -H "x-ms-blob-type: BlockBlob" "https://{storageaccount}.blob.core.windows.net/backups/{file.dat}?{sas-token}" |
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
| /p:DeployOnBuild=true /p:DeployTarget=Package /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\" /p:IncludeSetACLProviderOnDestination=false /p:AutoParameterizationWebConfigConnectionStrings=false |
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
| DBCC SHRINKFILE ('data_0', TRUNCATE ONLY) | |
| DBCC SHRINKFILE ('log', TRUNCATE ONLY) | |
| -- view used/available space | |
| SELECT | |
| name, | |
| CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0 as SpaceUsedInMB, | |
| size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0 AS AvailableSpaceInMB | |
| FROM sys.database_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
| Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\VMICTimeProvider -Name Enabled -Value 0 | |
| Restart-Service "Windows Time" | |
| # check if domain controller is being used for time | |
| # (you don't want to see VM IC Time Synchronization Provider as the source) | |
| w32tm /query /source | |
| w32tm /query /status |
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
| # configure client for certificate authentication | |
| $clientCert = New-SelfSignedCertificate -Type Custom -Container vm-admin -Subject "CN=vm-admin" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.2","2.5.29.17={text}upn=vm-admin@localhost") -KeyUsage DigitalSignature,KeyEncipherment -KeyAlgorithm RSA -KeyLength 2048 -CertStoreLocation "Cert:\CurrentUser\My" | |
| Get-ChildItem Cert:\CurrentUser\My\$($clientCert.Thumbprint) | Export-Certificate -FilePath .\vm-admin.cer -Type CERT | |
| $publicKey = [System.Convert]::ToBase64String((Get-Content -Path .\vm-admin.cer -Encoding Byte)) | |
| # configure server | |
| $cert = New-SelfSignedCertificate -CertstoreLocation Cert:\LocalMachine\My -DnsName $env:COMPUTERNAME | |
| Enable-PSRemoting -SkipNetworkProfileCheck -Force | |
| Enable-WSManCredSSP -Role Server -Force | |
| New-Item -Path WSMan:\LocalHost\Listener -Transport HTTPS -Address * -CertificateThumbPrint $cert.Thumbprint –Force |
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
| Set-StrictMode -Version Lastest | |
| $ErrorActionPreference = "Stop" | |
| Logon-AzureRmAccount | |
| $appId = Read-Host "Enter application ID of service principal" | |
| $adApp = (Get-AzureRmADApplication -ApplicationId $appId)[0] | |
| $spnId = (Get-AzureRmADServicePrincipal -ServicePrincipalName $adApp.IdentifierUris[0])[0].ApplicationId.Guid | |
| $endDate = (Get-Date).AddYears(1) |
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
| $pfxFile = 'c:\path\to\cert.pfx' | |
| $password = Read-Host -Prompt 'password' -AsSecureString | |
| $cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 | |
| $cert.Import($pfxFile, $password, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable) | |
| $pfxBlob = [System.Convert]::ToBase64String($cert.Export([Security.Cryptography.X509Certificates.X509ContentType]::Pkcs12)) | |
| "THUMBPRINT: $($cert.Thumbprint)" | |
| "PFX BLOB: `n$pfxBlob" |
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
| $aesManaged = New-Object "System.Security.Cryptography.AesManaged" | |
| $aesManaged.Mode = [System.Security.Cryptography.CipherMode]::CBC | |
| $aesManaged.Padding = [System.Security.Cryptography.PaddingMode]::Zeros | |
| $aesManaged.BlockSize = 128 | |
| $aesManaged.KeySize = 256 | |
| $aesManaged.GenerateKey() | |
| [System.Convert]::ToBase64String($aesManaged.Key) |