Skip to content

Instantly share code, notes, and snippets.

View Create_K2_site.ps1
#Set Execution Policy if necessary using command below
#Set-ExecutionPolicy Unrestricted -Force
#--------------------------------
#Modules
#
Import-Module WebAdministration
#--------------------------------
#Variables
View Check for empty K2 roles.sql
SELECT dq.*,dqu.[User] FROM [Server].[DestQueue] dq LEFT JOIN [Server].[DestQueueUser] dqu ON dqu.QueueID = dq.ID
WHERE dqu.[user] IS NULL
@mikerodionov
mikerodionov / Get-VM-Guest-Info.ps1
Last active Apr 10, 2020
Function to get VM Guest Information from Hyper-V Server
View Get-VM-Guest-Info.ps1
# Source: http://www.yusufozturk.info/virtual-machine-manager/getting-virtual-machine-guest-information-from-hyper-v-server-2012r2.html
# Usage example: Get-VMGuestInfo -VMName TEST01 -HyperVHost VMHOSTT01
function Get-VMGuestInfo
{
<#
.SYNOPSIS
Gets virtual machine guest information
.EXAMPLE
View Create_NAT_Switch.ps1
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
View Check_SQL_backup_version.sql
#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
View Take_process_dump.ps1
# 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)
}
@mikerodionov
mikerodionov / Get_SQL_version_and_navigate_to_setup_folder.ps1
Last active Apr 21, 2019
Get installed SQL Server version (for all instances on server) and navigate to the relevant setup folder
View Get_SQL_version_and_navigate_to_setup_folder.ps1
# This scripts detecs installed SQL instances through registry and returns version information
$inst = (get-itemproperty 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server').InstalledInstances
foreach ($i in $inst)
{
$p=(Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL').$i
(Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL').$i
(Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$p\Setup").Edition
(Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$p\Setup").Version
$ver = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$p\Setup").Version
switch ($ver) {
View AD_DS_Check_GC_role.ps1
#Open PS session to one of your domain controllers if necessary:
Enter-PSSession -ComputerName cndrm-dc01 -Credential DOMAIN\administrator
#Select IsGlobalCatalog propery for your DCs:
Get-ADDomainController -Filter * | Select-Object -Property Name,IsGlobalCatalog | Format-Table -AutoSize
View AD_DS_Enable_GC.ps1
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'}
View Check table size in Oracle database.sql
SELECT segment_name, segment_type, bytes/1024/1024 MB
FROM user_segments
WHERE segment_type='TABLE' AND segment_name='YOUR_TABLE_NAME'
You can’t perform that action at this time.