This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function SendEmailWithEmbeddedImages([String] $to, [String] $subject, [String] $body, [String] $attachment, [array] $imageFiles) | |
{ | |
$htmlText = "<HTML>{0}</HTML>" | |
foreach ($imageFile in $imageFiles) { | |
$fileName = ExtractFileName $imageFile | |
$imageTag = [string]::Format("<img src='cid:{0}'>", $fileName) | |
$htmlText = $htmlText + $imageTag | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Microsoft.Office.Interop.Outlook.Application] $outlook = New-Object -ComObject Outlook.Application | |
$entries = $outlook.Session.GetGlobalAddressList().AddressEntries | |
$count = $entries.Count | |
$count | |
foreach($entry in $entries) | |
{ | |
[console]::WriteLine("{0}: {1}", $entry.Name, $entry.GetExchangeUser().MobileTelephoneNumber) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Outlook=NEW-OBJECT –comobject Outlook.Application | |
$Contacts=$Outlook.session.GetDefaultFolder(10).items | |
$Contacts | Format-Table FullName,MobileTelephoneNumber |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[array] $dataX = 0, 1, 2, 3, 4 | |
[array] $dataY = 0.9, 0.5, 0.2, 0.9, 0.99 | |
$excel = New-Object -ComObject Excel.Application | |
$excel.Visible = $true | |
$workbook = $excel.Workbooks.Add() | |
$sheet = $workbook.ActiveSheet | |
$counter = 0 | |
$counter = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# http://stackoverflow.com/questions/6848741/can-i-write-a-class-using-powershell | |
# | |
C:\PS>$source = @" | |
public class BasicTest | |
{ | |
public static int Add(int a, int b) | |
{ | |
return (a + b); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# http://stackoverflow.com/questions/25331407/powershell-to-create-line-chart-from-excel | |
# | |
#Test Data | |
$Data=("8/15/2014",3091),("8/14/2014",240),("8/13/2014",519),("8/12/2014",622),("8/11/2014",2132),("8/10/2014",1255),("8/9/2014",3240)|ForEach{[PSCustomObject][Ordered]@{'Date_to_Display'=$_[0];'Number_of_Computers'=$_[1]}} | |
$xlConditionValues=[Microsoft.Office.Interop.Excel.XLConditionValueTypes] | |
$xlTheme=[Microsoft.Office.Interop.Excel.XLThemeColor] | |
$xlChart=[Microsoft.Office.Interop.Excel.XLChartType] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Test Data | |
#$Data=("8/15/2014",3091),("8/14/2014",240),("8/13/2014",519),("8/12/2014",622),("8/11/2014",2132),("8/10/2014",1255),("8/9/2014",3240)|ForEach{[PSCustomObject][Ordered]@{'Date_to_Display'=$_[0];'Number_of_Computers'=$_[1]}} | |
$xlConditionValues=[Microsoft.Office.Interop.Excel.XLConditionValueTypes] | |
$xlTheme=[Microsoft.Office.Interop.Excel.XLThemeColor] | |
$xlChart=[Microsoft.Office.Interop.Excel.XLChartType] | |
$xlIconSet=[Microsoft.Office.Interop.Excel.XLIconSet] | |
$xlDirection=[Microsoft.Office.Interop.Excel.XLDirection] | |
$xl = new-object -ComObject Excel.Application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# from http://hmemcpy.com/2014/12/how-to-get-changes-files-from-svn-between-two-revisions-with-powershell/ | |
# | |
function Export-SvnDiff($repo, $fromRevision, $toRevision, $outputDirectory) | |
{ | |
$xpath = "/diff/paths/path[@kind='file' and (@item='added' or @item='modified')]" | |
[xml]$output = & svn diff -r $("{0}:{1}" -f $fromRevision, $toRevision) $repo --summarize --xml | |
$output | Select-Xml -XPath $xpath | % { $_.node."#text" } | % { | |
$targetFile = Resolve-FullPath (Join-Path $outputDirectory ($_ -replace $repo)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#http://stackoverflow.com/questions/4284991/parsing-nested-parentheses-in-python-grab-content-by-level | |
def parenthetic_contents(string): | |
"""Generate parenthesized contents in string as pairs (level, contents).""" | |
stack = [] | |
for i, c in enumerate(string): | |
if c == '(': | |
stack.append(i) | |
elif c == ')' and stack: | |
start = stack.pop() | |
yield (len(stack), string[start + 1: i]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#http://stackoverflow.com/questions/23219400/splitting-a-string-python-within-a-list | |
>>> import re | |
>>> i = 'john(is,great),paul,school' | |
>>> re.split(r',+(?=[^()]*(?:\(|$))', i) | |
['john(is,great)', 'paul', 'school'] |