Skip to content

Instantly share code, notes, and snippets.

Thom Schumacher crshnbrn66

View GitHub Profile
View get-ccmlog.ps1
function Get-CMLog
{
<#
.SYNOPSIS
Parses logs for System Center Configuration Manager.
.DESCRIPTION
Accepts a single log file or array of log files and parses them into objects. Shows both UTC and local time for troubleshooting across time zones.
.PARAMETER Path
Specifies the path to a log file or files.
.INPUTS
View parseAndConnectToOracle.ps1
param($tnsnamesPath = 'c:\tns\tnsnames.ora',$username = 'user',$password = 'gotmehere', $connectionName = 'mustard', $query = 'Select sysdate from dual')
$simplySQLPath = (Get-Module -ListAvailable simplySQL).ModuleBase
if($simplySQLPath -and (test-path $tnsnamesPath -PathType Leaf) -and (![string]::IsNullOrEmpty($node)))
{
[System.Reflection.Assembly]::LoadFile("$simplySQLPath\DataReaderToPSObject.dll") | OUT-NULL
Import-Module SimplySql -Force
$parsedTN = (get-content $tnsnamesPath -raw) -replace '(.*\=.*|\n.*\=)(.*|\n.*)\(DESCRIPTION*.\=' ,'Data Source = (DESCRIPTION ='
$splitTN = $parsedTN -split '(?=.*Data Source = \(DESCRIPTION \=)'
$tnsnames = $splitTN |?{$_ -like "*$connectionName*"}
$connstring = "$tnsnames;User Id=$username;Password=$password"
View DacToFile.ps1
param($dacpacPath = 'c:\dacpacPath', $dacpac = 'your.dacpac')
add-type -path 'C:\Program Files (x86)\Microsoft SQL Server\120\DAC\bin\Microsoft.SqlServer.Dac.Extensions.dll'
cd $dacpacPath
$model =[Microsoft.SqlServer.Dac.Model.TSqlModel]::new(((get-item ".\$dacpac").fullname))
$queryScopes = [Microsoft.SqlServer.Dac.Model.DacQueryScopes]::All
$returnObjects = $model.GetObjects([Microsoft.SqlServer.Dac.Model.DacQueryScopes]::All)
$s = ''
foreach($r in $returnObjects)
{
if ($r.TryGetScript([ref]$s))
View MonitorConnection.ps1
function Start-ConnectionMonitoring
{
param($isp, $gateway, $Logfile,[int]$Delay = 10,[Ipaddress] $adapter, [switch]$ispPopup, [switch]$gateWayPopup)
$spacer = '--------------------------'
while($true)
{
if(!(Test-Connection $gateway -source $adapter -count 1 -ea Ignore))
{
get-date | Add-Content -path $Logfile
"$gateWay Connection Failure" |add-content -Path $Logfile
@crshnbrn66
crshnbrn66 / update-AppSettings.ps1
Created Oct 20, 2017
Script to demonstrate hashtable merging in powershell and updating web applications in azure
View update-AppSettings.ps1
param($websitename = 'TEst' ,$resourceGroup = 'SchuTest',$slot = 'production', $appSettings ='{"AppSettings:testkey1": "45test","AppSettings:TestId": "This is a Test Key 28"}')
#https://stackoverflow.com/questions/8800375/merging-hashtables-in-powershell-how
Function Merge-Hashtables([ScriptBlock]$Operator) {
$Output = @{}
ForEach ($Hashtable in $Input) {
If ($Hashtable -is [Hashtable]) {
ForEach ($Key in $Hashtable.Keys) {$Output.$Key = If ($Output.ContainsKey($Key)) {@($Output.$Key) + $Hashtable.$Key} Else {$Hashtable.$Key}}
}
}
If ($Operator) {ForEach ($Key in @($Output.Keys)) {$_ = @($Output.$Key); $Output.$Key = Invoke-Command $Operator}}
View write-user
function Write-User
{
param(
[parameter(mandatory)]
[string]$fileName
)
write-output "Username: $env:UserName" | tee-object -filepath $filename
write-output "Current Command: $($MyInvocation.MyCommand.Path)" | tee-object -filepath $filename
write-output "Current Script: $($MyInvocation.MyCommand.ScriptName)"| tee-object -filepath $filename
View Deploy-Reports.ps1
param
(
[String] [Parameter(Mandatory)]
$SolutionFile,
#this is the evironment that is in the Solution config to read where things need to go (TEST/DEV/QA/Prodution)
#for example - C:\tfs2013\Test Automated Deployment Sharepoint.rptproj
[string] [Parameter(Mandatory)] $Environment,
#this is the name of the Datasource as it exists in Sharepoint without the .rsds extension
[string] [Parameter(Mandatory)] $DataSource,
#This is the connection string that will be set for the report data source.
View SubScriptionExporter.ps1
#Requires -Version 5.0
#------------------------------------------------------------------------
# Source File Information (DO NOT MODIFY)
# Source ID: 8967ce63-8512-4998-b597-b65331d6a9f6
# Source File: subscriptionExporter.psf
#------------------------------------------------------------------------
#region File Recovery Data (DO NOT MODIFY)
<#RecoveryData:
d00BAB+LCAAAAAAABACMu9eOs0CbLnreUt/Dr/+U0ZhosDQzEjlHk8/IGUwy4ep39QTtJe0tzfpa
beHPVLnqDU8A+t+cIpu+xXJxyZb8AxyszTT++z/Rf0X++R+/P//4x7+ZS1M1Y9ILTV8YyVD8x7qn
@crshnbrn66
crshnbrn66 / Compare-ObjectEquivalence.ps1
Created Jun 6, 2017 — forked from KirkMunro/Compare-ObjectEquivalence.ps1
A function that facilitates comparison of serialized objects with their deserialized or selected equivalent
View Compare-ObjectEquivalence.ps1
function Compare-ObjectEquivalence {
[CmdletBinding(DefaultParameterSetName='Deserialized')]
param(
[Parameter(Position=0, Mandatory=$true)]
[ValidateNotNull()]
[System.Object]
$OriginalObject,
[Parameter(Position=1, Mandatory=$true, ParameterSetName='Deserialized')]
[ValidateNotNull()]
View create-SSRSDataDrivenSub.ps1
$reportExportPath = 'C:\temp\reports'
$reportFiles = Get-ChildItem $reportExportPath -Filter *.xml
foreach($file in $reportFiles)
{
$reportobject = Import-Clixml -path ($file.fullname)
#$extensionsettings = [SSRSProxy.ExtensionSettings]::new()
$extensionSettings = New-Object -typename 'SSRSProxy.ExtensionSettings'
$extensionSettings.Extension = $reportobject.Subscriptions.properties.extensionSettings.Extension
$paramvalues = @()
foreach($parameterField in $reportobject.Subscriptions.properties.extensionSettings.ParameterValues)
You can’t perform that action at this time.