Skip to content

Instantly share code, notes, and snippets.

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 / user-profile.psm1
Last active Sep 24, 2021 — forked from MSAdministrator/Create-NewProfile.ps1
PowerShell functions to create a new user profile
View user-profile.psm1
<#
.Synopsis
Rough PS functions to create new user profiles
.DESCRIPTION
Call the Create-NewProfile function directly to create a new profile
.EXAMPLE
Create-NewProfile -Username 'testUser1' -Password 'testUser1'
.NOTES
Created by: Josh Rickard (@MS_dministrator) and Thom Schumacher (@driberif)
View Get-FileNameProperties.ps1
function Get-FileNameProperties
{
param( $path = "~",
[switch] $Recurse,
[array]$Properties = ('Fullname', 'LastAccessTime', 'LastWriteTime', 'CreationTime','Owner','Size','Directory','Extension'))
$sortedfiles = $null
$files = Get-ChildItem -Recurse:$Recurse -File $path #if $recurse is true it'll recurse other wise it won't
$params2 = @()
View NTFS.psm1
# http://stackoverflow.com/a/13519264
#http://msdn.microsoft.com/en-us/library/system.security.accesscontrol.filesystemrights%28v=vs.110%29.aspx
function Remove-PermissionsForGroup
{
<#
.Synopsis
Removes Ntfs permissions for the directory specified..
.DESCRIPTION
This script sets the ntfs permissions for the directory passed.
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 Get-RedirectedUrls.ps1
function get-redirectedUrls
{
Param($url)
$urlcheckobject=@{}
$Uri = [uri]$url
$url2check = $url
do{
$value = get-redirectedUrl -url $url2check
if($value.redirect)
{
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
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
@crshnbrn66
crshnbrn66 / Compare-iisSites.ps1
Last active Jun 16, 2020
Retrieves IIS settings from remote machines and presents difference view in winmerge
View Compare-iisSites.ps1
#Requires -Modules webadministration
#Requires -RunAsAdministrator
#Requires -version 3.0
<#
.SYNOPSIS
Provides a means to get the current backup location for iis changes
.DESCRIPTION
Changes made to the IIS instance are recorded in a history config file. This function provides the means to retreive where it is on the machine
View Copy-code.ps1
#requires -version 5.0
using namespace System.IO
using namespace System.IO.Compression
param(
[Parameter(Mandatory=$true)][string]$sourceZip,
[Parameter(Mandatory=$true)][string]$destPath
)
add-type -assemblyname 'System.IO.Compression'
add-type -assemblyname 'System.IO.Compression.FileSystem'