Skip to content

Instantly share code, notes, and snippets.

Set-ADObject "CN=NTDS Settings,CN=DOMAINCONTROLLER-NAME,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=DOMAIN,DC=COM" -Replace @{options='1'}
# Specify process name
$ProcName = "K2HostServer"
$procid=get-process $ProcName |select -expand id
# Create target folder if not exist:
$DumpPath="C:\dumps"
If (!(Test-Path $DumpPath))
{
Write-Host 'Creating folder'
(New-Item $DumpPath -ItemType Directory | out-null)
}
#This script retrieves SQL Server version from BAK file and allows you to compare with your SQL Server version
#If your SQL Server version is lower that one which was used to create backup you won't be able to restore BAK file
$BakFile= Read-Host "Provide full path to SQL BAK file (including file name with extension)"
$VerDetectQuery="RESTORE HEADERONLY FROM DISK='$BakFile'"
$BakMajorVer=Invoke-Sqlcmd -Query $VerDetectQuery | Select-Object -ExpandProperty SoftwareVersionMajor
$BakMinorVer=Invoke-Sqlcmd -Query $VerDetectQuery | Select-Object -ExpandProperty SoftwareVersionMinor
$BakBuildVer=Invoke-Sqlcmd -Query $VerDetectQuery | Select-Object -ExpandProperty SoftwareVersionBuild
$BakVer= "$BakMajorVer.$BakMinorVer.$BakBuildVer.0"
$ServerSQLVer=Invoke-Sqlcmd -Query "SELECT SERVERPROPERTY('productversion')" | Select-Object -ExpandProperty Column1
New-VMSwitch -SwitchName “NATSwitch” -SwitchType Internal
New-NetIPAddress -IPAddress 192.168.210.1 -PrefixLength 24 -InterfaceAlias “vEthernet (NATSwitch)”
New-NetNAT -Name “NATNetwork” -InternalIPInterfaceAddressPrefix 192.168.210.0/24
SELECT dq.*,dqu.[User] FROM [Server].[DestQueue] dq LEFT JOIN [Server].[DestQueueUser] dqu ON dqu.QueueID = dq.ID
WHERE dqu.[user] IS NULL
#Set Execution Policy if necessary using command below
#Set-ExecutionPolicy Unrestricted -Force
#--------------------------------
#Modules
#
Import-Module WebAdministration
#--------------------------------
#Variables
Get-VM | Format-List Name,Generation
# Checkout repo which needs history clear up
# Assuming repo has default "main" name
git checkout --orphan latest_branch
# Once current state checked out to local folder add all files
git add -A
# Commit "the changes"
git commit -am "Repo clear up"
# Delete your original remote branch
git branch -D main
# Rename the current branch to main
# Install required module
Install-Module -Name VSTeam -Scope CurrentUser
# Specify your Azure DevOps project
Set-VSTeamAccount -Account <Name of your Azure DevOps org> -PersonalAccessToken <Your PAT with access to your project>
# Request pipeline validation:
Test-VSTeamYamlPipeline -Project <PROJECT_NAME> -PipelineId <PIPELINE_ID> -FilePath '<PATH_TO_YAML_FILE>'
@mikerodionov
mikerodionov / SQL_Components_Clean_Up.ps1
Last active December 5, 2021 12:18
Cleanup of SQL components
# This is something which can be useful if you run into error message below during SQL Server installation
# The MOF compiler could not connect with the WMI server - Error in UI
# MSINEWINSTANCE requires a new instance that is not installed - Error in SQL installer logs
# View all installed components which name contains SQL
Get-WmiObject -Query "SELECT * FROM win32_product Where Caption like '%SQL%'" | Select Caption, IdentifyingNumber
# Build a list of commands to uninstall all of them
$components_to_delete = Get-WmiObject -Query "SELECT * FROM win32_product Where Caption like '%SQL%'" | Select -ExpandProperty IdentifyingNumber
foreach ($component in $components_to_delete) {
echo "msixec /x $component"
}