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
#requires -version 2.0 | |
<# | |
author: Johan Vosloo | |
date: 24/11/2011 | |
purpose: Retrieve event id’s from multiple machines and add to a CSV file. | |
#> | |
Try | |
{ | |
$servers=get-content c:\scripts\servers.txt | |
$date=(Get-Date).AddDays(-7) |
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
# | |
# Populate a list of servers where the only thing to change between servers is the number: | |
# | |
$servers = 1..10 | %{"ccioaxpi{0:00}edc" -f $_} ` | |
+ 1..2 | %{"ccioaxpf{0:00}edc" -f $_} | |
#This is the equivelant to: | |
#$servers = 'ccioaxpi01edc','ccioaxpi02edc','ccioaxpi03edc','ccioaxpi04edc','ccioaxpi05edc','ccioaxpi06edc','ccioaxpi07edc','ccioaxpi08edc','ccioaxpi09edc','ccioaxpi10edc','ccioaxpf01edc','ccioaxpf02edc' |
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
--::example batch file: | |
--pushd \\ukexchange\sysgrp\scripts\sql | |
--sqlcmd -S ccioaxpd05edc\axeam_train -i \\ukexchange\sysgrp\scripts\sql\grantsysadmin.sql -E -o \\ukexchange\sysgrp\scripts\sql\GrantSysAdmin.rpt | |
--popd | |
--sql file: | |
-- - usage: | |
-- sqlcmd -S <server\instance> -i \\ukexchange\sysgrp\scripts\sql\grantsysadmin.sql -E -o \\ukexchange\sysgrp\scripts\sql\GrantSysAdmin.rpt | |
use master | |
go |
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
[Enum]::GetValues([System.ConsoleColor]) | %{ Write-Host $_ -ForegroundColor $_ } |
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
::ensure 7zip directory is added to path environment variable (%programfiles%\7-zip) | |
7z x *.zip -o* |
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 [ax-support1-uatb] | |
go | |
DBCC SHRINKFILE (N'EnergyLive' , 0, TRUNCATEONLY) | |
--(get file name from db's properties) |
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
$adDummy = New-Object –TypeName PSObject –Prop @{ | |
emailSearched = $null; | |
notFound = $true; | |
sAmAccountName = $null; | |
fullname = $null; | |
firstname = $null; | |
lastname = $null; | |
cn = $null; | |
countryCode = $null; | |
country = $null; |
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
#NB: replace "." with instance name (e.g. ".\sqlexpress" or "axlive\sql06") | |
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null | |
New-Object -typeName Microsoft.SqlServer.Management.Smo.Server(".") | select edition, version |
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
powershell | |
cls | |
function testme { | |
param( | |
[Parameter( | |
Position=0, | |
Mandatory=$true, | |
ValueFromPipeline=$true, | |
ValueFromPipelineByPropertyName=$true) |
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
$a = ipconfig | |
$a | |
# Reverse array contents and then output it again: | |
[array]::Reverse($a) | |
$a |