Skip to content

Instantly share code, notes, and snippets.

View crshnbrn66's full-sized avatar

Thom Schumacher crshnbrn66

View GitHub Profile
@crshnbrn66
crshnbrn66 / Get-WebAppPoolStatus.ps1
Created November 13, 2015 22:31
Get the last time app pool was Restarted.
function get-webApppoolstatus($pool)
{
$poolReturn = @()
$poolStatus = gwmi win32_process -filter "Name like '%w3wp%'" | select name, Processid, commandline, creationdate
#$poolstatus.converttodatetime($poolStatus.creationdate)
foreach($status in $poolStatus)
{
if(($status.commandline) -like "*$pool*" -and ($pool -ne $null))
{
$status.creationdate = [System.Management.ManagementDateTimeConverter]::ToDateTime($status.creationdate)
#This gets the group information in a functioncall used by two other functions
function getComputerGroup
{ param($strComputer, $strGroup)
$computer = [ADSI]('WinNT://' + $strComputer + ',computer')
$Group = $computer.psbase.children.find($strGroup)
return $Group
}
# This will list what’s currently in a Group so you can verify the result
function listUsers
{ param($strComputer, $strGroup)
function Test-FileOpen
{
<#
.SYNOPSIS
Tests to see if a file is locked
.DESCRIPTION
Returns true if the file can be opened. False if the file is open already.
.PARAMETER path to file
@crshnbrn66
crshnbrn66 / SQLJob.ps1
Last active January 11, 2016 16:51
Script to create Sql jobs / query them and steps
#http://sqlblog.com/blogs/allen_white/archive/2008/01/09/create-agent-jobs-to-run-powershell-scripts.aspx
#https://msdn.microsoft.com/en-us/library/ms162162.aspx
#Requires -Version 3.0
function Get-SqlJobs
{
param([string]$sqlServer, [string]$sqlinstance = $null)
$s = New-SqlServerConnection -sqlServer $sqlServer -sqlinstance $sqlinstance
$jobs = $s.JobServer.Jobs
$jobs
}
#http://www.iis.net/learn/extensions/configuring-application-request-routing-(arr)/achieving-high-availability-and-scalability-arr-and-nlb
# This script is used in octopus to deploy ARR to host targetted for it.
#
function stop-WAS
{
$i = 0
$service = get-service WAS -ErrorAction SilentlyContinue
if($service)
{
param
(
[String]
[Parameter(Mandatory)]
$SourceFolder,
[String]
$Destination ,
[string]
$AdminUserName,
[string]
@crshnbrn66
crshnbrn66 / backupBuildRelease.ps1
Created February 9, 2017 19:19
Backup TFS 2013 release 3 build and release definitions
function Backup-TFSReleaseDefinitions
{
param([object]$tfsprojs,$tfsurl = 'mytfsinstance.com', $tfscollection = 'Defaultcollection', $apiversion = '3.0-preview',[string]$Path = 'c:\temp\tfsprojects')
$tfsInstance = "http://$($tfsurl):8080/tfs/$tfsCollection"
foreach($tfsproj in $tfsprojs.value)
{
$tfsProjName = $tfsproj.name
$tfsdev = "$tfsInstance/$tfsProjName"
$projectIds = Invoke-RestMethod -Method Get -UseDefaultCredentials -uri "$tfsdev/_apis/release/definitions?api-version=$apiversion" -ContentType application/json
@crshnbrn66
crshnbrn66 / CreateProfile.ps1
Last active March 24, 2017 22:09 — forked from adamdriscoll/CreateProfile.ps1
Create profile
function CreateProfile
{
param([String]$UserSid, [String]$UserName, [system.uint32]$ProfilePath)
Add-Type -TypeDefinition '
using System;
using System.Runtime.InteropServices;
public static class PInvoke {
[DllImport("userenv.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern int CreateProfile( [MarshalAs(UnmanagedType.LPWStr)] String pszUserSid, [MarshalAs(UnmanagedType.LPWStr)] String pszUserName, [Out, MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszProfilePath, uint cchProfilePath);
}
$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)
#requires -version 5.0
function Get-DataDrivenSubscriptionProperties
{
param([object] $Subscription,
[object]$ssrsproxy)
$ssrsobject = [SSRSObject]::New()
$sid = $Subscription.SubscriptionID
$ddextensionSettings = $ddDataRetrievalPlan = $ddDescription = $ddactive = $ddstatus = $ddeventtype = $ddmatchdata = $ddparameters = $Null
$ddOwner = $ssrsproxy.GetDataDrivenSubscriptionProperties($sid,[ref]$ddextensionSettings,[ref]$ddDataRetrievalPlan`
,[ref]$ddDescription,[ref]$ddactive,[ref]$ddstatus,[ref]$ddeventtype,[ref]$ddmatchdata,[ref]$ddparameters)