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
[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
$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
[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
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
# | |
# sample: | |
#$title = "MyChart" | |
#$size = "700x350" | |
#$url = CreateChartUrl $valueArray $labelArray $title $size | |
# | |
function CreateChartUrl ($valueArray, $labelArray, [string]$title, $size) { | |
$chartType = "lc" | |
$chartData = [string]::join(",", $valueArray) |
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 SendEmailWithEmbeddedImage([String] $to, [String] $subject, [String] $body, [String] $attachment, [String] $imageFile) | |
{ | |
#$htmlHeader = "<HEAD>Text<B>BOLD</B> <span style='color:#E36C0A'>Color Text</span></HEAD>" | |
$htmlText = "<HTML>{0}</HTML><img src='cid:{1}'>" | |
$Outlook = New-Object -ComObject Outlook.Application | |
$Mail = $Outlook.CreateItem(0) | |
$Mail.To = $to #"boss@company.com" | |
$Mail.Subject = $subject | |
$Mail.HTMLBody = [string]::Format($htmlText, $body, ExtractFileName $imageFile) |
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
. "$PSScriptRoot\genericFunctions.ps1" | |
# | |
# | |
# | |
<actual powershell source, can use functions from file genericFunction.ps1> |
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/1153126/how-to-create-a-zip-archive-with-powershell | |
# | |
# | |
# $zipFileName contains path to new .zip file | |
# $sourceDir contains path to folder with source data | |
# | |
ZipFiles $zipFileName $sourceDir |
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
# | |
# | |
# References: | |
# http://ardalis.com/How-Can-I-View-MSMQ-Messages-and-Queues | |
# to see queue, search via "Computer Mamagment" | |
# | |
# simular sample: http://blogs.msdn.com/b/sajay/archive/2010/03/18/powershell-script-to-create-an-msmq.aspx | |
# | |
[Reflection.Assembly]::LoadWithPartialName("System.Messaging") |