This file contains hidden or 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 CreateCSV(InputMessageName,OutputMessageName,Delimiter) | |
Set sb = Application.CreateStringBuilder | |
If IsNull(Delimiter) OR IsEmpty(Delimiter) Then | |
Delimiter = ";" | |
End If | |
If IsNull(OutputMessageName) OR IsEmpty(OutputMessageName) Then | |
OutputMessageName = "CSV" | |
End If |
This file contains hidden or 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
Find = chr(34) | |
Str = "This is string with " & chr(34) & "double quotes" & chr(34) & "." | |
Occurrences = (Len(Str) - Len(Replace(Str,Find,Empty)) / Len(Find)) | |
MsgBox "String: " & Str & vbCrLf &_ | |
"Contains :" & Occurrences & " occurrences of: " & Find & "." | |
Function GetOccurrences(InputString,LookupString) | |
If _ | |
IsNull(InputString) Or IsEmpty(InputString) Or _ | |
IsNull(LookupString) Or IsEmpty(LookupString) _ |
This file contains hidden or 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
$ps = New-Object System.Diagnostics.ProcessStartInfo | |
$ps.FileName = 'explorer' | |
$ps.Arguments = '/select, ' + $Path | |
[System.Diagnostics.Process]::Start($ps) |
This file contains hidden or 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 Get-MongoEventLog ( | |
[Parameter(Position=0)][string] $Regex = '.*', | |
[Parameter(Position=1)][string] $Log = $null | |
) | |
{ | |
# Check to see if we are running the 64 bit version of Powershell. | |
# See http://stackoverflow.com/questions/2897569/visual-studio-deployment-project-error-when-writing-to-registry | |
if ([intptr]::size -eq 8) { $mongoDriverPath = (Get-ItemProperty "HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v3.5\AssemblyFoldersEx\MongoDB CSharpDriver 1.2").'(default)'; } | |
else { $mongoDriverPath = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\.NETFramework\v3.5\AssemblyFoldersEx\MongoDB CSharpDriver 1.2").'(default)'; } |
This file contains hidden or 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 Get-MongoEventLog ( | |
[Parameter(Position=0)][string] $Regex = '.*', | |
[Parameter(Position=1)][string] $Log = $null | |
) | |
{ | |
Add-Type -Path "bin\MongoDB.Bson.dll"; | |
Add-Type -Path "bin\MongoDB.Driver.dll"; | |
$db = [MongoDB.Driver.MongoDatabase]::Create('mongodb://localhost/powershell'); | |
[MongoDB.Driver.MongoCollection] $collection = $db['eventlogs'] |
This file contains hidden or 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
# Check to see if we are running the 64 bit version of Powershell. | |
# See http://stackoverflow.com/questions/2897569/visual-studio-deployment-project-error-when-writing-to-registry | |
if ([intptr]::size -eq 8) { | |
$mongoDriverPath = (Get-ItemProperty "HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v3.5\AssemblyFoldersEx\MongoDB CSharpDriver 1.2").'(default)'; | |
} | |
else { $mongoDriverPath = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\.NETFramework\v3.5\AssemblyFoldersEx\MongoDB CSharpDriver 1.2").'(default)'; } | |
Add-Type -Path "$($mongoDriverPath)\MongoDB.Bson.dll"; | |
Add-Type -Path "$($mongoDriverPath)\MongoDB.Driver.dll"; |
This file contains hidden or 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
$mongoDriverPath = "$(Split-Path -Parent $MyInvocation.MyCommand.Path)\bin"; | |
Add-Type -Path "$($mongoDriverPath)\MongoDB.Bson.dll"; | |
Add-Type -Path "$($mongoDriverPath)\MongoDB.Driver.dll"; | |
$bsonDoc = [MongoDB.Bson.BsonDocument] @{ | |
Name = 'firstname surname' | |
EmailAddresses = '[email protected]','[email protected]' | |
}; | |
#$bsonDoc.ToHashtable() |
This file contains hidden or 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
$Group = Read-Host 'Specify Group'; | |
[void][System.Reflection.Assembly]::LoadWithPartialName('System.DirectoryServices.AccountManagement'); | |
([System.DirectoryServices.AccountManagement.GroupPrincipal]::FindByIdentity([System.DirectoryServices.AccountManagement.ContextType]::Domain,$Group)).GetMembers(1); |
This file contains hidden or 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 Get-Diacritic | |
{ | |
Param | |
( | |
[Parameter(Mandatory=$true)][ValidateScript({Test-Path $_})][String]$Path, | |
[Parameter(Mandatory=$True)][String[]]$Recepient, | |
[Switch]$AsHTML | |
) | |
$email = @{ |
This file contains hidden or 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 Get-Uptime { | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory = $true, ValueFromPipeline = $true)][string[]]$ComputerName=$env:COMPUTERNAME | |
) | |
begin | |
{} | |
process { | |
$obj = New-Object PSObject | |
$obj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $ComputerName[0] |