Skip to content

Instantly share code, notes, and snippets.

@jamessantiago
jamessantiago / BitsFolderCopy.ps1
Last active December 11, 2015 20:09
Script to copy a directory using bits and retain it's structure
Import-Module BitsTransfer
$s = "C:\Source"
$d = "D:\Destination"
xcopy.exe /T /E $s $d
ls $s -Recurse |? {! $_.PSIsContainer} |% {
$e = $_.FullName.Remove(0, $s.Length + 1)
start-bitstransfer $($_.FullName) $d\$e
}
$a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
$ToTest = {
"AAAAAAA"
"AAAAAAAA"
"AAAAAAAAA"
"AAAAAAAAAA"
"AAAAAAAAAAA"
"AAAAAAAAAAAA"
"AAAAAAAAAAAAA"
#you can use this as a script or just run these three commands one at a time
import-module bitstransfer
#kick off the transfer
start-bitstransfer -source "large file" -destination "folder" -asyncronous -displayname MyTransfer
#monitor transfer and restart if failed
1..1000|% {sleep (60); get-bitstransfer -name MyTransfer |% {if ($_.jobstate -eq "Transferring") {write-host $($_.bytestransfered / $_.bytestotal)} elseif ($_.jobstate -like "error") {resume-bitstransfer $_; "resuming after error"} elseif ($_.jobstate -like "Transferred") {complete-bitstransfer $_; exit}}
$logs = 'c:\windows\system32\ccm\logs\smstslog'
if (-not (test-path $logs))
{
exit 0
}
$tsenv = new-object -comobject Microsoft.SMS.TSEnvironment
$computer = ""
if ($tsenv -ne $null)
{
@jamessantiago
jamessantiago / Powershell.csx
Created December 27, 2013 06:46
MMBot script for use with the MMBot.Powershell package
//Notes:
//Requires the MMBot.Powershell nuget package
//Output objects must either support a ToString method or be a string to display properly
//It is recommended to use the PowershellModule script instead of this one to control what is executed
using MMBot.Powershell;
var robot = Require<Robot>();
robot.Respond(@"(ps|powershell) (.*)", msg =>
@jamessantiago
jamessantiago / PowershellModule.csx
Created December 27, 2013 06:47
MMBot script for use with the MMBot.Powershell package
//Notes:
//Requires the MMBot.Powershell nuget package
//Specify the powershell scripts folder using the MMBOT_POWERSHELL_SCRIPTSPATH key in the ini file
//Powershell scripts must be .psm1 (modules) to be executed
//Only scripts inside the scripts folder may be executed using this script
//Output objects must either support a ToString method or be a string to display properly
using MMBot.Powershell;
var robot = Require<Robot>();
@jamessantiago
jamessantiago / Get-DiskUsage.psm1
Last active January 1, 2016 12:59
Example psm1 script for use with the MMBot.Powershell package
function Get-DiskUsage {
<#
.SYNOPSIS
Gives details on disk free space
.DESCRIPTION
Returns a list of drives on the local machine
.NOTES
Name: Get-DiskUsage
Author: James Santiago
DateCreated: 08/21/2013
@jamessantiago
jamessantiago / timbo.ps1
Last active August 29, 2015 14:05
Timbo Shell
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class Tricks {
[DllImport("user32.dll")]
public static extern IntPtr GetForegroundWindow();
}
"@
1..60 |% {

Keybase proof

I hereby claim:

  • I am jamessantiago on github.
  • I am jamessantiago (https://keybase.io/jamessantiago) on keybase.
  • I have a public key whose fingerprint is 2D51 FA1E 42DE AF48 33FC 021D BAF3 C497 EC8C F91C

To claim this, I am signing this object:

@jamessantiago
jamessantiago / GenerateResolutions.ps1
Created October 14, 2014 06:58
Generate Background resolutions for windows lock screen
[reflection.assembly]::LoadWithPartialName("System.Drawing") | Out-Null
#1920x1200 is the starting image, doesn't have to be this resolution
$baseImage = New-Object system.drawing.bitmap $pwd\1920x1200.jpg
$files = @"
Background1024x1280.jpg
Background1024x1280.jpg
Background1024x768.jpg
Background1280x1024.jpg