Skip to content

Instantly share code, notes, and snippets.

@crshnbrn66
crshnbrn66 / Get-WebAppPoolStatus.ps1
Created Nov 13, 2015
Get the last time app pool was Restarted.
View Get-WebAppPoolStatus.ps1
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)
View gui-localuser.ps1
#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)
View Test-FileOpen
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 Jan 11, 2016
Script to create Sql jobs / query them and steps
View SQLJob.ps1
#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
}
View setup-arr.ps1
#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)
{
View Gui-SSRS-Deploy.ps1
#------------------------------------------------------------------------
# Source File Information (DO NOT MODIFY)
# Source ID: 9ad32074-7adb-4822-a049-93600f966aa9
# Source File: ..\Documents\SAPIEN\Projects\Gui-SSRS-Deploy\Gui-SSRS-Deploy.psproj
#------------------------------------------------------------------------
#region Project Recovery Data (DO NOT MODIFY)
<#RecoveryData:
CAIAAB+LCAAAAAAABACNkV1rgzAUhu8L/Q/ifepHxU6IuVhdyy72QS27Had6HBkxkUTH/PeLU4dl
MHb5JO95XnJCT1ioD9R9Bi2w9cpx6LNW71i032DxBbXhSrJgE1BvhunuwAXeZyyBchv6u4jsoLyQ
6CYMCfhRQpJt7PtVEscACfWm8DQ6tZz7BplPvSXOciVKW+d4yzYzwYTOCSvUKAt8hBpT13VuOy7K
View deployspapp.ps1
param
(
[String]
[Parameter(Mandatory)]
$SourceFolder,
[String]
$Destination ,
[string]
$AdminUserName,
[string]
@crshnbrn66
crshnbrn66 / backupBuildRelease.ps1
Created Feb 9, 2017
Backup TFS 2013 release 3 build and release definitions
View backupBuildRelease.ps1
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
View CreateProfile.ps1
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);
}
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)