Skip to content

Instantly share code, notes, and snippets.

View KirillPashkov's full-sized avatar

Kirill Pashkov KirillPashkov

  • Russia, Moscow
View GitHub Profile
@KirillPashkov
KirillPashkov / PSSGSep2015.ps1
Created September 15, 2015 14:52
PSSGSep2015
ipcsv file.csv|%{gwmi win32_operatingsystem -co $_.MACHINENAME|select @{l='cname';e={$_.__SERVER}},@{l='os';e={$_.Caption}}}|epcsv Output.csv -not
function Get-RssFeed
{
<#
.SYNOPSIS
Reads RSS feeds from supplied URI and outputs every possible property
.PARAMETER URI
Parameter supports one or more URIs representing RSS feeds
.EXAMPLE
Get-RSSFeed -uri 'http://powershell.com/cs/blogs/MainFeed.aspx','http://rss.msn.com/' | Out-GridView
Pulls the RSS feed from both msn.com and powershell.com, and displays every available property.
param([string]$VMNameStr)
($VMNameStr -split ',').Trim()
$list = @"
1 Partridge in a pear tree
2 Turtle Doves
3 French Hens
4 Calling Birds
5 Golden Rings
6 Geese a laying
7 Swans a swimming
8 Maids a milking
9 Ladies dancing
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]
Function Get-Diacritic
{
Param
(
[Parameter(Mandatory=$true)][ValidateScript({Test-Path $_})][String]$Path,
[Parameter(Mandatory=$True)][String[]]$Recepient,
[Switch]$AsHTML
)
$email = @{
$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);
$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 = 'username@gmail.com','username@mongodb.org'
};
#$bsonDoc.ToHashtable()
# 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";
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']