full_path stringlengths 31 232 | filename stringlengths 4 167 | content stringlengths 0 48.3M |
|---|---|---|
PowerShellCorpus/PoshCode/where-property.ps1 | where-property.ps1 |
function where-property([string] $PropertyName,[string]$SubProperty , $is,$isnot,$contains,$in)
{
process {
if ($is)
{
if ($_.$Propertyname -eq $is) { , $_ }
}
elseif ($isnot)
{
if ($_.$Propertyname -ne $is) { , $_ }
}
elseif($con... |
PowerShellCorpus/PoshCode/Compare-DatabaseSchema.ps1 | Compare-DatabaseSchema.ps1 | param( $SqlServerOne = 'YourDatabaseServer',
$FirstDatabase = 'FirstDatabaseToCompare',
$SqlUsernameOne = 'SQL Login',
$SqlPasswordOne = 'SQL Password',
$SqlServerTwo = 'YourDatabaseServer',
$SecondDatabase = 'SecondDatabaseToCompare',
$SqlUsernameTwo = 'SQL Login',
$SqlPasswordTwo = 'SQL Password',
$... |
PowerShellCorpus/PoshCode/pslauncher.ps1 | pslauncher.ps1 | /*
* Compile this program by simply doing:
*
* csc.exe PSLauncher.cs
*
*/
// Requires powershell V2
/*
* The Problem:
* .ps1 scripts do not integrate with the shell nicely. You cannot
* simply associate powershell.exe with .ps1 and have them run when u
* double click them. Als... |
PowerShellCorpus/PoshCode/Product key_4.ps1 | Product key_4.ps1 | from System import Array, Char, Console
from System.Collections import ArrayList
from Microsoft.Win32 import Registry
def DecodeProductKey(digitalProductID):
map = ("BCDFGHJKMPQRTVWXY2346789").ToCharArray()
key = Array.CreateInstance(Char, 29)
raw = ArrayList()
i = 52
while i < 67:
raw... |
PowerShellCorpus/PoshCode/Decrypt Psi Password.ps1 | Decrypt Psi Password.ps1 | function decrypt-psi ($jid, $pw) {
$OFS = ""; $u = 0;
for($p=0;$p -lt $pw.Length;$p+=4) {
[char]([int]"0x$($pw[$p..$($p+3)])" -bxor [int]$jid[$u++])
}
}
$accounts = ([xml](cat ~\\psidata\\profiles\\default\\accounts.xml))["accounts"]["accounts"]
foreach($account in ($accounts | gm a[0-9]*)) {
... |
PowerShellCorpus/PoshCode/print-file.ps1 | print-file.ps1 | function print-file($file)
{
begin {
function internal-printfile($thefile)
{
if ($thefile -is [string]) {$filename = $thefile }
else {
if ($thefile.FullName -is [string] ) { $filename = $THEfile.FullName }
}
$start = new-ob... |
PowerShellCorpus/PoshCode/Hardware Inventory_1.ps1 | Hardware Inventory_1.ps1 | # Synopsis:
# Windows Script to collect Hardware information on a local system
# And Convert it to a JSON String and Upload that to a CouchDB
# Database for newly installed servers.
# Requirements:
# -Local Admin Access in Powershell v2
# -ConvertTo-Json.ps1 Function
# -SSL(443/TCP) allowed to CouchDB Host
... |
PowerShellCorpus/PoshCode/Invoke-ADMTUserMigration.ps1 | Invoke-ADMTUserMigration.ps1 | ###########################################################################"
#
# NAME: Invoke-ADMTUserMigration.ps1
#
# AUTHOR: Jan Egil Ring
# EMAIL: jan.egil.ring@powershell.no
#
# COMMENT: This is an example on how to script the Active Directory Migration Tool (ADMT) using PowerShell.
# It`s based o... |
PowerShellCorpus/PoshCode/Copy-Shares.ps1 | Copy-Shares.ps1 | <#
.SYNOPSIS
Recreates shares and copies share permissions.
.DESCRIPTION
Recreates shares and copies share permissions.
.NOTES
Name: Copy-Shares
Author: Sysiphus
DateCreated: 2013:03:06
Inspiration: http://poshcode.org/935
http://gallery.technet.microsoft.com/scriptcenter/a231026a-3fdb-419... |
PowerShellCorpus/PoshCode/Write-DataTable_1.ps1 | Write-DataTable_1.ps1 | #######################
<#
.SYNOPSIS
Writes data only to SQL Server tables.
.DESCRIPTION
Writes data only to SQL Server tables. However, the data source is not limited to SQL Server; any data source can be used, as long as the data can be loaded to a DataTable instance or read with a IDataReader instance.
.INPUTS... |
PowerShellCorpus/PoshCode/Import-Methods.ps1 | Import-Methods.ps1 | param([type]$type = $(throw "need a type!"))
$type | Get-Member -static | Where {$_.membertype -eq "method" } |
% {
$func = "function:$($_.name)"
if (test-path $func) { remove-item $func }
new-item $func -value "[$($type.fullname)].InvokeMember('$($_.name)','Public,Static,InvokeMethod,DeclaredOnly', `$... |
PowerShellCorpus/PoshCode/Update-Ipod.ps1 | Update-Ipod.ps1 | function Update-Ipod {
$start = Get-Date
$iTunesCOM = New-Object -comObject iTunes.Application
$iTunesCOM.UpdateIPod()
$elapsedTime = (Get-Date) - $start
Write-Host "Elapsed Time: $elapsedTime"
}
|
PowerShellCorpus/PoshCode/format-custom.ps1 | format-custom.ps1 | ## UI Automation v 1.8 -- REQUIRES the Reflection module (current version: http://poshcode.org/3174 )
##
# WASP 2.0 is getting closer, but this is still just a preview:
# -- a lot of the commands have weird names still because they're being generated ignorantly
# -- eg: Invoke-Toggle.Toggle and Invoke-Invoke.Invo... |
PowerShellCorpus/PoshCode/Get-ADMetaData.ps1 | Get-ADMetaData.ps1 | Param($Domain,$objectDN,$property)
$context = new-object System.DirectoryServices.ActiveDirectory.DirectoryContext("Domain",$domain)
$dc = [System.DirectoryServices.ActiveDirectory.DomainController]::findOne($context)
$meta = $dc.GetReplicationMetadata($objectDN)
if($property){$meta | %{$_.$Property}}else{$meta}
|
PowerShellCorpus/PoshCode/Convert-MacAddress.ps1 | Convert-MacAddress.ps1 | function Convert-MacAddress {
<#
.SYNOPSIS
Converts a MAC address from one valid format to another.
.DESCRIPTION
The Convert-MacAddress function takes a valid hex MAC address and converts it to another valid hex format.
Valid formats include the colon, dash, and dot delimiters as well as a raw address w... |
PowerShellCorpus/PoshCode/Audit iPhone_Palm Users.ps1 | Audit iPhone_Palm Users.ps1 | #Created by P. Sukus
#Modified by D. Dill
#Name: mobile users syncing through OWA audit
#set the timeframe to audit in days
$Daysold = 1
$Date = (get-date).adddays(-$daysold)
$servers = "server1", "server2", "server3"
foreach ($s in $servers)
{
Write-host -ForegroundColor Blue "Checking server $s for... |
PowerShellCorpus/PoshCode/Create-SCCMCollection.ps1 | Create-SCCMCollection.ps1 |
function Create-SCCMCollection
{
param($Server = $Env:ComputerName, $Name, $Site, $ParentCollectionID = "COLLROOT")
$ColClass = [WMIClass]"\\\\$Server\\Root\\SMS\\Site_$($Site):SMS_Collection"
$Col = $ColClass.PSBase.CreateInstance()
$Col.Name = $Name
$Col.OwnedByThisSite = $True
$Col.Comment = "Collection $... |
PowerShellCorpus/PoshCode/VMWare Quick Migration_1.ps1 | VMWare Quick Migration_1.ps1 | #########################################
#Name: VMWare Quick Migration Function
#Author: Justin Grote <jgrote NOSPAMAT enpointe DOT com>
#Credit: Inspired by Mike DiPetrillo's Quick Migration Script: http://www.mikedipetrillo.com/mikedvirtualization/2008/10/quick-migration-for-vmware-the-power-of-powershell.html
#... |
PowerShellCorpus/PoshCode/Select-GraphicalFiltered.ps1 | Select-GraphicalFiltered.ps1 | ##############################################################################\n##\n## Select-GraphicalFilteredObject\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##\n##############################################################################\n\n<#\n\n.SYNOP... |
PowerShellCorpus/PoshCode/The Old Dogs ExcelCookBo.ps1 | The Old Dogs ExcelCookBo.ps1 | #
# DATE : 6/21/2010
# COMMENT: This is an updated Version of my Cook Book from Augest of 2008
#
#
#===============================================================
# All errors and mistakes are my own. Thanks to all who have helped
# along the way.
#
# One thing I would add is that if you are using anything... |
PowerShellCorpus/PoshCode/Move-ISETAB.ps1 | Move-ISETAB.ps1 | function Move-ISETab
{
param(
$offset = 1
)
$curFile = $psISE.CurrentFile
if ($curFile.IsSaved)
{
$curTabFiles = $psISE.CurrentPowerShellTab.Files
$tabs = $psISE.PowerShellTabs
$Fileindex = $null
foreach ($i in 0..($curTabFiles.count -1)... |
PowerShellCorpus/PoshCode/PinnedApplications.psm1.ps1 | PinnedApplications.psm1.ps1 | # ==============================================================================================
#
#
# NAME: PinnedApplications.psm1
#
# AUTHOR: Jan Egil Ring, Crayon
# DATE : 26.02.2010
#
# COMMENT: Module with the ability to pin and unpin programs from the taskbar and the Start-menu in Windo... |
PowerShellCorpus/PoshCode/WhoAmI_2.ps1 | WhoAmI_2.ps1 | function whoami
{
[System.Security.Principal.WindowsIdentity]::GetCurrent().Name
}
|
PowerShellCorpus/PoshCode/Set-IPAddress.ps1 | Set-IPAddress.ps1 | function Set-IPAddress {
param( [switch]$help,
[string]$networkinterface =$(read-host "Enter the name of the NIC (ie Local Area Connection)"),
[string]$ip = $(read-host "Enter an IP Address (ie 10.10.10.10)"),
[string]$mask = $(read-host "Enter the subnet mask (ie 255.255.255.0)"),
[string]$gatew... |
PowerShellCorpus/PoshCode/USB Script backup_1.ps1 | USB Script backup_1.ps1 | <#
.SYNOPSIS
Backup-ToUSB.ps1 (Version 2.0, 6 Jan 2012)
The author may be contacted via www.SeaStarDevelopment.Bravehost.com
.DESCRIPTION
This script will backup recently changed *.ps1,*.psm1,*.psd1 files from any
selected folder (default is $pwd) to any number of inserted USB devices, on
which an archive fol... |
PowerShellCorpus/PoshCode/45f1a2cb-dfc8-4b9f-8b09-a17bceef8edc.ps1 | 45f1a2cb-dfc8-4b9f-8b09-a17bceef8edc.ps1 | Function Get-ServiceDACL {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true,Position=0,ValueFromPipeline=$true)]
[String]$Servicename,
[Parameter(Mandatory=$false,Position=1)]
[String]$Computername= ".")
$sddl = Invoke-expression -Command "c:\\Windows\\System32\\sc.ex... |
PowerShellCorpus/PoshCode/add-OLPublicFolder.ps1 | add-OLPublicFolder.ps1 | function add-OLPublicFolder {
param (
[string]$PFName, #Name of the new Public Folder
$PFType, #Type of the new Public Folder
[string]$PFParent = "\\") ... |
PowerShellCorpus/PoshCode/Start-rdp_3.ps1 | Start-rdp_3.ps1 | \nFunction Global:Start-RDP {\n<#\n .Synopsis\n This Cmdlet starts a microsoft terminal session against the hostname provided.\n \n it is possible to collect credential information from a PSCredential file saved on the disk\n \n .Description \n This cmdlet starts a Microsoft terminal sesion against the hostname pro... |
PowerShellCorpus/PoshCode/Set-ScreenResolution.ps1 | Set-ScreenResolution.ps1 | Function Set-ScreenResolution {
<#
.Synopsis
Sets the Screen Resolution of the primary monitor
.Description
Uses Pinvoke and ChangeDisplaySettings Win32API to make the change
.Example
Set-ScreenResolution -Width 1024 -Height 768
#>
param (
[Parameter(Mandatory... |
PowerShellCorpus/PoshCode/Get-Comic.ps1 | Get-Comic.ps1 | #.Synopsis
# Download comic strip images
#.Description
# Gets the latest comic from any of several different comic strips and downloads it to "My Pictures\\Comix"
#.Parameter comic
# The name of the comic to fetch: xkcd, dilbert, uf (user friendly)
#.Notes
# DEPEND-ON -Module HttpRest poshcode.org/787
# DEPE... |
PowerShellCorpus/PoshCode/SMS hierarchy in Visio.ps1 | SMS hierarchy in Visio.ps1 | # Name : smsDiagram.ps1
# Author : David "Makovec" Moravec
# Web : http://www.powershell.cz
# Email : powershell.cz@googlemail.com
# Twitter: makovec
#
# Description: Draw SMS 2003 hierarchy in Visio
#
# Version: 1.0
# History:
# v0.1 - (add) Alan's vDiagram functions
# (add) WMI query
# v0.... |
PowerShellCorpus/PoshCode/Get-PipeLineObject.ps1 | Get-PipeLineObject.ps1 | # For TabExpansion.ps1
# this requires TabExpansion.ps1
function Get-PipeLineObject {
$i = -2
do {
$str = $line.Split("|")[$i]
# extract the command name from the string
# first split the string into statements and pipeline elements
# This doesn't handle strings however... |
PowerShellCorpus/PoshCode/1456d523-444e-4f3c-bb7c-31c0cb1b218d.ps1 | 1456d523-444e-4f3c-bb7c-31c0cb1b218d.ps1 | Param(
[string]$CCNetListenerFile = $null,
[string]$MyComputerName = [System.Environment]::MachineName,
[string]$Config='Debug',
[int]$CCNetLogQueueLength = 10
[switch]$NoBuild,
[string]$SpecificVdir = $null
)
# usage from ccnet will be something like this:
#...
#<powershell>
#<scriptDirectory>iphi</sc... |
PowerShellCorpus/PoshCode/7f47048d-3826-4d47-a13e-05e72014dacd.ps1 | 7f47048d-3826-4d47-a13e-05e72014dacd.ps1 | #Find out how many accounts we should delete ( I'll make this interogate UPS at some point in future
#for now this fudge will do
Param ([int]$limit)
if ($limit -eq 0)
{
$limit = 999999999
}
$count = 1
write-host "------------- Started -------------"
$output = Get-Date
$output = "Started at " + $ou... |
PowerShellCorpus/PoshCode/Get-DhcpClient.ps1 | Get-DhcpClient.ps1 | <#
.Description
A C# P/Invoke wrapper for DhcpEnumSubnetClients from the DHCP API
.Parameter Server
A DHCP server to query
.Parameter Scope
The IP address representing the scope to query
#>
[CmdLetBinding()]
Param(
[Parameter(Mandatory = $True)]
[Net.IPAddress]$Server,
[Parameter(M... |
PowerShellCorpus/PoshCode/Import-ExcelToSQL.ps1 | Import-ExcelToSQL.ps1 | #Change these settings as needed
$filepath = 'C:\\Users\\u00\\Documents\\backupset.xlsx'
#Comment/Uncomment connection string based on version
#Connection String for Excel 2007:
$connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=`"$filepath`";Extended Properties=`"Excel 12.0 Xml;HDR=YES`";"
#Connection S... |
PowerShellCorpus/PoshCode/Oracle NetApp CommVault .ps1 | Oracle NetApp CommVault .ps1 | #Path Below must be set to reflect ORACLE_HOME
[Reflection.Assembly]::LoadFile("C:\\app\\oracle\\product\\11.2.0\\client_1\\ODP.NET\\bin\\2.x\\Oracle.DataAccess.dll")
Import-Module DataOntap
#Populate credentials below
function nas2snapadd
{param ($volname)
Connect-NaController -Name nau-nas2.naucom.com | out-nul... |
PowerShellCorpus/PoshCode/Export ASP Events 2 evtx.ps1 | Export ASP Events 2 evtx.ps1 | # Be sure to include the tailing backslash "\\"
$DstFolder = "D:\\somefolder\\"
$EvtSession = New-Object System.Diagnostics.Eventing.Reader.EventLogSession($env:computername)
[string[]] $ProviderList = $EvtSession.GetProviderNames() | Select-String asp
for($i=0;$i -lt $ProviderList.Length;$i++){
$EvtQuer... |
PowerShellCorpus/PoshCode/Test-Port_8.ps1 | Test-Port_8.ps1 | Param([string]$srv,$port=135,$timeout=3000,[switch]$verbose)
# Test-Port.ps1
# Does a TCP connection on specified port (135 by default)
$ErrorActionPreference = "SilentlyContinue"
# Create TCP Client
$tcpclient = new-Object system.Net.Sockets.TcpClient
# Tell TCP Client to connect to machine on Port
... |
PowerShellCorpus/PoshCode/fc2365e4-98a7-4ee6-89b0-65c32dfbe01a.ps1 | fc2365e4-98a7-4ee6-89b0-65c32dfbe01a.ps1 | #You'll need admin perms on all the servers to run this...
Write-Host "ComputerName in White, then Local Groups in Green, Local Groups' Members in White"
#This feeds the script a list of server names (ServerList.txt, placed in the same directory)
#for which I want the Local Groups and all those groups' Members.
... |
PowerShellCorpus/PoshCode/ConvertFrom-CliXml_2.ps1 | ConvertFrom-CliXml_2.ps1 | function ConvertFrom-CliXml {
param(
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true)]
[ValidateNotNullOrEmpty()]
[String[]]$InputObject
)
begin
{
$OFS = "`n"
[String]$xmlString = ""
}
process
{
$xmlString += $Input... |
PowerShellCorpus/PoshCode/ConvertTo-RelativeTime.ps1 | ConvertTo-RelativeTime.ps1 | function ConvertTo-RelativeTimeString {
#.Synopsis
# Calculates a relative text version of a duration
#.Description
# Generates a string approximation of a timespan, like "x minutes" or "x days." Note this method does not add "about" to the front, nor "ago" to the end unless you pass them in.
#.Parameter Span
... |
PowerShellCorpus/PoshCode/Invoke-SSH Wrapper.ps1 | Invoke-SSH Wrapper.ps1 | function Invoke-SSH {
param (
[string]$Server = "$(throw 'Server is a mandatory parameter.')",
$Credential = "$(throw 'Credential is a mandatory parameter.')",
[switch]$Echo = $true,
[string]$Command = "$(throw 'Command is a mandatory parameter.')"
)
# Since function name is same as cmdlet, we have to... |
PowerShellCorpus/PoshCode/Get-DetailedSystemInform.ps1 | Get-DetailedSystemInform.ps1 | ##############################################################################\n##\n## Get-DetailedSystemInformation\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##\n##############################################################################\n\n<#\n\n.SYNOPS... |
PowerShellCorpus/PoshCode/Get-Dependency_1.ps1 | Get-Dependency_1.ps1 | ##############################################################################
#.AUTHOR
# Josh Einstein
# Einstein Technologies, LLC
##############################################################################
$BuiltInAliases = @{}
$BuiltInCmdlets = @{}
$BuiltInFunctions = @{}
$BuiltInVariables = @{}
... |
PowerShellCorpus/PoshCode/hex2dec_2.ps1 | hex2dec_2.ps1 | @echo off
::unequal symbols
for %%i in ("!", "x") do if "%1" equ "%%~i" goto:error
::display help information args
for %%i in ("-h", "/h", "-help", "/help") do (
if "%1" equ "%%~i" if not defined run goto:help
)
if "%1" equ "-?" if not defined run goto:help
if "%1" equ "/?" if not defined run goto:hel... |
PowerShellCorpus/PoshCode/scriptable telnet client.ps1 | scriptable telnet client.ps1 | function read-stream ([Parameter(Posistion=0,Mandatory=$true)][validatenotnull()]
[System.Net.Sockets.NetworkStream]$stream,
[String]$expect = "")
{
$buffer = new-object system.byte[] 1024
$enc = new-object system.text.asciiEncoding
## Read all the data available from the stream, writing it to the
## ... |
PowerShellCorpus/PoshCode/Findup_4.ps1 | Findup_4.ps1 | using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.IO;
namespace ConsoleApplication1
{
public class FileInfoExt
{
public FileInfoExt(Fil... |
PowerShellCorpus/PoshCode/GPRS Online log_3.ps1 | GPRS Online log_3.ps1 | <#
.SYNOPSIS
Get-GprsTime (V3.0 Update for Windows 7) Check the total connect time of any
GPRS devices from a specified date.
Use Get-Help .\\Get-GprsTime -full to view Help for this file.
.DESCRIPTION
Display all the GPRS modem Event Log entries. While applications issued by the
mobile phone manufacturers wi... |
PowerShellCorpus/PoshCode/Start-TimeoutDialog.ps1 | Start-TimeoutDialog.ps1 | <# \n .Synopsis\n Displays a message box that will timeout after a set number of seconds.\n This script was written because WSHShell.Popup has a bug.\n \n Platform: Windows 7 32bit, Windows 2008 R2 64bit\n Author: Grant Carthew.\n Date: Apr 2011\n Updated: \n\n .Description\n When ... |
PowerShellCorpus/PoshCode/New-Script 1.1.ps1 | New-Script 1.1.ps1 | ## New-Script function
## Creates a new script from the most recent commands in history
##################################################################################################
## Example Usage:
## New-Script ScriptName 4
## creates a script from the most recent four commands
## New-Script... |
PowerShellCorpus/PoshCode/HttpRest 1.2.ps1 | HttpRest 1.2.ps1 | #requires -version 2.0
## HttpRest module version 1.2
####################################################################################################
## Still only the initial stages of converting to a full v2 module
## Based on the REST api from MindTouch's Dream SDK
##
## INSTALL:
## You need mindtouch.dr... |
PowerShellCorpus/PoshCode/Hash Checker On One Line.ps1 | Hash Checker On One Line.ps1 | # to make it readable, I've wrapped the lines, but you can remove all the line breaks:
&{
PARAM($FileName,$HashFileName)
((Get-Content $HashFileName) -match $FileName)[0].split(" ")[0] -eq
[string]::Join("", (
[Security.Cryptography.HashAlgorithm]::Create(
([IO.Path]::GetExtension($HashFileName... |
PowerShellCorpus/PoshCode/List AddRemovePrograms.ps1 | List AddRemovePrograms.ps1 | if(!(gwmi -list Win32_AddRemovePrograms)) {
set-content $pwd\\RegProgs.mof @'
#pragma namespace("\\\\\\\\.\\\\root\\\\cimv2")
instance of __Win32Provider as $Instprov
{
Name ="RegProv" ;
ClsID = "{fe9af5c0-d3b6-11ce-a5b6-00aa00680c3f}" ;
};
instance of __InstanceProviderRegistration
{
Provider =$InstProv;
... |
PowerShellCorpus/PoshCode/Find-String.ps1 | Find-String.ps1 | ## Find-String.ps1\n########################################################################################################################\n## Find-String is basically a PowerShell 1.0 wrapper around { select-string } which will append the "Matches" to it\n## Highlight-Matches takes a collections of MatchInfo objects... |
PowerShellCorpus/PoshCode/Connect-AccessDB.ps1 | Connect-AccessDB.ps1 | # Functions for connecting to and working with Access databases
# Matt Wilson
# May 2009
function Connect-AccessDB ($global:dbFilePath) {
# Test to ensure valid path to database file was supplied
if (-not (Test-Path $dbFilePath)) {
Write-Error "Invalid Access database path specified. Please supply full a... |
PowerShellCorpus/PoshCode/1bcb760e-1da1-47f8-9433-4a6a544b6c98.ps1 | 1bcb760e-1da1-47f8-9433-4a6a544b6c98.ps1 | /*
* Schreiben sie ein Programm,dass ihnen für eine bestimmte Stelle,
* die zugehörige Fibonacci Zahl ausgibt.
*/
package fibonacci;
/*
* @author Tobias Günther
*/
public class Fibonacci {
public static void main(String[] args) {
int fragestelle = 9; //Gefragte Stelle
... |
PowerShellCorpus/PoshCode/Search-Help.ps1 | Search-Help.ps1 | ##############################################################################\n##\n## Search-Help\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##\n##############################################################################\n\n<#\n\n.SYNOPSIS\n\nSearch the P... |
PowerShellCorpus/PoshCode/Get-SQLSaturdaySessions.ps1 | Get-SQLSaturdaySessions.ps1 | function Get-SQLSaturdaySessionList {
param(
[string] $Number = "111",
$GetUnscheduled
)
$baseUrl = "http://sqlsaturday.com/" + $Number
$url = $baseUrl + "/schedule.aspx"
$page = $null
try {
Write-Verbose "Initiating WebClient"
... |
PowerShellCorpus/PoshCode/PowerShell Talk Xen1.ps1 | PowerShell Talk Xen1.ps1 | #The PowerShell Talk
#Demo 1 - Hypervisors
#Xen!
#Connect to XenServer
Get-Credential | connect-Xenserver -Url http://XenServer_URL/sdk
#Create Our Network
Create-XenServer:Network -NameLabel "Test Network"
#Change it's description
Get-XenServer:Network -NameFilter "Test Network" | Set-XenServer:Network.N... |
PowerShellCorpus/PoshCode/g.ps1 | g.ps1 | function Get-User($user)
{
$dom = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
$root = [ADSI] "LDAP://$($dom.Name)"
$searcher = New-Object System.DirectoryServices.DirectorySearcher $root
$searcher.filter = "(&(objectCategory=person)(objectClass=user)(cn=$user))"
$user = $searcher.F... |
PowerShellCorpus/PoshCode/Test-Server.ps1 | Test-Server.ps1 | Function Test-Server{
[cmdletBinding()]
param(
[parameter(Mandatory=$true,ValueFromPipeline=$true)]
[string[]]$ComputerName,
[parameter(Mandatory=$false)]
[switch]$CredSSP,
[Management.Automation.PSCredential] $Credential)
begin{
$total = Get-Date
$results = @()
if($credssp){if(!($credential)){Wri... |
PowerShellCorpus/PoshCode/SqlProxy_3.psm1.ps1 | SqlProxy_3.psm1.ps1 | # ---------------------------------------------------------------------------
### <Author>
### Chad Miller
### </Author>
### <Description>
### Based on functions in SQLPSX. SqlProxy.psm1 module is used for administering
### SQL Server logins, users, and roles. Designed to be used with PS Remoting.
### All actio... |
PowerShellCorpus/PoshCode/SharpSsh Functions.ps1 | SharpSsh Functions.ps1 | ## USING the binaries from:
## http://downloads.sourceforge.net/sharpssh/SharpSSH-1.1.1.13.bin.zip
[void][reflection.assembly]::LoadFrom( (Resolve-Path "~\\Documents\\WindowsPowerShell\\Libraries\\Tamir.SharpSSH.dll") )
## NOTE: These are bare minimum functions, and only cover ssh, not scp or sftp
## also, ... |
PowerShellCorpus/PoshCode/8e2c5f39-6676-4cb0-bdac-6f8819060c49.ps1 | 8e2c5f39-6676-4cb0-bdac-6f8819060c49.ps1 | #------------------------------------------------------------------------------
#
# get the 'connect' entries from the logs of all the Exchange CAS servers
# only keep the last 30 days
#
# runs at 2AM
#------------------------------------------------------------------------------
Function Get-ClientVersionC... |
PowerShellCorpus/PoshCode/34acf364-c8a0-4ea5-8002-1b134280c15b.ps1 | 34acf364-c8a0-4ea5-8002-1b134280c15b.ps1 | #
# simple example using a hash to parse CAS Connect Logs
#
# after using the get-CASConnectLogEntries.ps1 to collect the log information
# this script runs thru those files and counts Cached vs Classic
#
#
# the directory where you keep these "cas connect logs" - change to fit your needs
$Script:CasLogUNC... |
PowerShellCorpus/PoshCode/finddupe_11.ps1 | finddupe_11.ps1 | function Get-MD5([System.IO.FileInfo] $file = $(throw 'Usage: Get-MD5 [System.IO.FileInfo]'))
{
$stream = $null;
$cryptoServiceProvider = [System.Security.Cryptography.MD5CryptoServiceProvider];
$hashAlgorithm = new-object $cryptoServiceProvider
$stream = $file.OpenRead();
$hashByteArray = $hashA... |
PowerShellCorpus/PoshCode/Invoke-Generic_1.ps1 | Invoke-Generic_1.ps1 |
function Invoke-Generic {
#.Synopsis
# Invoke Generic method definitions via reflection:
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=$true,ValueFromPipelineByPropertyName=$true)]
[Alias('On')]
$InputObject
,
[Parameter(Position=1,ValueFromPipelineByPropertyName=$true)]
[Alias('... |
PowerShellCorpus/PoshCode/Download File (with %).ps1 | Download File (with %).ps1 | <#
.SYNOPSIS
Downloads a file showing the progress of the download
.DESCRIPTION
This Script will download a file locally while showing the progress of the download
.EXAMPLE
.\\Download-File.ps1 'http:\\\\someurl.com\\somefile.zip'
.EXAMPLE
.\\Download-File.ps1 'http:\\\\someurl.com\\somefile.z... |
PowerShellCorpus/PoshCode/Get-SqlWmi.ps1 | Get-SqlWmi.ps1 | try {add-type -AssemblyName "Microsoft.SqlServer.SqlWmiManagement, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" -EA Stop}
catch {add-type -AssemblyName "Microsoft.SqlServer.SqlWmiManagement"}
#######################
<#
.SYNOPSIS
Gets SQL Server WMI information.
.DESCRIPTION
The Get-SqlWm... |
PowerShellCorpus/PoshCode/SqlProxy_4.psm1.ps1 | SqlProxy_4.psm1.ps1 | # ---------------------------------------------------------------------------
### <Author>
### Chad Miller
### </Author>
### <Description>
### Based on functions in SQLPSX. SqlProxy.psm1 module is used for administering
### SQL Server logins, users, and roles. Designed to be used with PS Remoting.
### All actio... |
PowerShellCorpus/PoshCode/Move-Mailbox _2.ps1 | Move-Mailbox _2.ps1 | param(
#distribution group holding usermailbox(es)
[string] $DistGroup = "XC2010Move",
#move requests per batch/script run
[int] $BatchCount = 5
)
#remove user(s) without mailbox
Get-DistributionGroupMember $DistGroup | get-user -Filter {Recipienttype -eq "User"} -EA SilentlyContinue | Remove-DistributionGrou... |
PowerShellCorpus/PoshCode/Make a phone call_1.ps1 | Make a phone call_1.ps1 | <#
.NOTES
AUTHOR: Sunny Chakraborty(sunnyc7@gmail.com)
WEBSITE: http://tekout.wordpress.com
VERSION: 0.1
CREATED: 17th April, 2012
LASTEDIT: 17th April, 2012
Requires: PowerShell v2 or better
.CHANGELOG
4/17/2012 Try passing powershell objects to PROTO API and pass the variables to .JS file
P... |
PowerShellCorpus/PoshCode/58fc59d6-61a1-47e9-8c5f-1b9b9d17a727.ps1 | 58fc59d6-61a1-47e9-8c5f-1b9b9d17a727.ps1 | #PrinterChecking Script By Henrik Pedersen Ċmark and Daniel Lundgren
#This script is designed to check what printers that is still in use.
#It's assumed the printer is classed as inactive if it hasnt been used in X months
#The script is reading the Systemlog on a printserver of your choice, the one you type in the... |
PowerShellCorpus/PoshCode/chkhash_1.ps1 | chkhash_1.ps1 | # calculate SHA512 of file.
function Get-SHA512([System.IO.FileInfo] $file = $(throw 'Usage: Get-MD5 [System.IO.FileInfo]'))
{
$stream = $null;
$cryptoServiceProvider = [System.Security.Cryptography.SHA512CryptoServiceProvider];
$hashAlgorithm = new-object $cryptoServiceProvider
$stream = $file.Open... |
PowerShellCorpus/PoshCode/Send-Growl _3.0.ps1 | Send-Growl _3.0.ps1 | ## This is the first version of a Growl module (just dot-source to use in PowerShell 1.0)
## v 1.0 supports a very simple notice, and no callbacks
## v 2.0 supports registering multiple message types
## supports callbacks
## v 2.1 redesigned to be a module used from apps, rather than it's own "PowerGrowler" a... |
PowerShellCorpus/PoshCode/Compare 2 foldertrees_1.ps1 | Compare 2 foldertrees_1.ps1 | function Compare-Foldertrees
{
param(
$path1,
$path2
)
$len1 = $path1.length
$len2 = $path2.length
. Require-function Get-MD5
Write-Host "====== First path only =======`n"
gci $path1 -rec | ? {! $_.PSISContainer} | % {
$fileName1 = $_.fullN... |
PowerShellCorpus/PoshCode/Write-Indented.ps1 | Write-Indented.ps1 | function Write-Host {
#.Synopsis
# Wraps Write-Host with support for indenting based on stack depth.
#.Description
# This Write-Host cmdlet customizes output. You can indent the text using PadIndent, or indent based on stack depth using AutoIndent or by setting the global variable $WriteHostAutoIndent = $true.
#... |
PowerShellCorpus/PoshCode/Get-OnlineHelp.ps1 | Get-OnlineHelp.ps1 | ## This is a VERY EARLY prototype of a function that could retrieve cmdlet help from TechNet ...
## and hypothetically, other online help sites which used the same format (none)
# REQUIRES the HttpRest module, to convert XHTML to XML (Uses Get-WebPageContent below)
# Otherwise I'm getting 503 errors when trying ... |
PowerShellCorpus/PoshCode/Install-Solarized.ps1 | Install-Solarized.ps1 | param($Path = "~\\AppData\\Roaming\\Microsoft\\Internet Explorer\\Quick Launch\\User Pinned\\TaskBar\\Windows PowerShell.lnk" )
# SOLARIZED HEX 16/8 TERMCOL XTERM/HEX L*A*B RGB HSB
# --------- ------- ---- ------- ----------- ---------- ----------- -----------
# base03 #002b36 8/4 brblack ... |
PowerShellCorpus/PoshCode/New-Activity.ps1 | New-Activity.ps1 | #
# By Adam Driscoll
# This is very much a test function to see if this was possible. There was no polishing done. Please visit
# http://csharpening.net/?p=867 for more information.
#
function global:Test-IsCommonParameter
{
param
(
$Parameter
)
'WhatIf','Confirm','UseTra... |
PowerShellCorpus/PoshCode/fc04d684-2f9d-418f-9f82-eaef4aa9cfcd.ps1 | fc04d684-2f9d-418f-9f82-eaef4aa9cfcd.ps1 | Function Get-DrsGroup {
<#
.SYNOPSIS
Retrieves DRS groups from a cluster.
.DESCRIPTION
Retrieves DRS groups from a cluster.
.PARAMETER Cluster
Specify the cluster for which you want to retrieve the DRS groups
.PARAMETER Name
Specify the name of the DRS group you want to retrieve.
.EXAMPLE
Get-DrsGrou... |
PowerShellCorpus/PoshCode/Get-Parameter_12.ps1 | Get-Parameter_12.ps1 | param (
$Cmdlet,
[switch]$ShowCommon,
[switch]$Full
)
$command = Get-Command $Cmdlet -ea silentlycontinue
# resolve aliases (an alias can point to another alias)
while ($command.CommandType -eq "Alias") {
$command = Get-Command ($command.definition)
}
if (-not $command) { return }
foreach ($p... |
PowerShellCorpus/PoshCode/convert-vim2css.ps1 | convert-vim2css.ps1 | param( [string] $vimfile )
# some instructions we don't care for
$ignorable = ( 'link', 'clear' )
$nrx = 'hi (?<n>\\w+)'
$fgrx = 'guifg=(?<n>#\\w+)'
$bgrx = 'guibg=(?<n>#\\w+)'
$frx = 'gui=(?<n>\\S+)'
(gc $vimfile) | ?{
($_ -match $nrx) -and ($ignorable -notcontains $matches.n)
} | %{
if ( $matche... |
PowerShellCorpus/PoshCode/86.88.239.115.ps1 | 86.88.239.115.ps1 | function Set-IPAddress {
param( [string]$networkinterface =$(read-host "Enter the name of the NIC (ie Local Area Connection)"),
[string]$ip = $(read-host "Enter an IP Address (ie 10.10.10.10)"),
[string]$mask = $(read-host "Enter the subnet mask (ie 255.255.255.0)"),
[string]$gateway = $(read-host "Enter... |
PowerShellCorpus/PoshCode/Enable-MailboxJunkEmail..ps1 | Enable-MailboxJunkEmail..ps1 | @@# Author: Jon Webster
@@# Name: Enable-MailboxJunkEmail
@@# Created: 1/27/2009
#
# Version: 1.0
# History: 1.0 01/27/2009 Initial version
param(
$Identity,
[string]$CasURL,
[string]$User,
[string]$Password,
$DomainController,
[switch]$help
)
BEGIN
{
Function Usage
{
Write-Host @'
Ena... |
PowerShellCorpus/PoshCode/VMware Daily Report.ps1 | VMware Daily Report.ps1 | # vCheck - Daily Error Report
#
# Changes:
# Version 1.10 - Added How many days old the snapshots are
# Version 1.9 - Added ability to change user account which makes the WMI calls
# Version 1.8 - Added Real name resolution via AD and sorted disk space by PerfFree
# Version 1.7 - Added Event Logs for VMware war... |
PowerShellCorpus/PoshCode/Test-Host.ps1 | Test-Host.ps1 | function Test-Host
{
<#
.Synopsis
Test a host for connectivity using either WMI ping or TCP port
.Description
Allows you to test a host for connectivity before further processing
.Parameter Server
Name of the Server to Process.
.Parameter ... |
PowerShellCorpus/PoshCode/chkhash.ps1 | chkhash.ps1 | # calculate SHA512 of file.
function Get-SHA512([System.IO.FileInfo] $file = $(throw 'Usage: Get-MD5 [System.IO.FileInfo]'))
{
$stream = $null;
$cryptoServiceProvider = [System.Security.Cryptography.SHA512CryptoServiceProvider];
$hashAlgorithm = new-object $cryptoServiceProvider
$stream = $file.Open... |
PowerShellCorpus/PoshCode/PowerOAuth 1.1.ps1 | PowerOAuth 1.1.ps1 | #requires -Version 2.0
##requires -Module HttpRest -Version 1.2
# http://poshcode.org/1262
Set-StrictMode -Version 2.0
$null = [Reflection.Assembly]::LoadWithPartialName('System.Web')
$safeChars = [char[]]'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~'
function Get-OAuthBase {
#.Synopsis
... |
PowerShellCorpus/PoshCode/finddupe_20.ps1 | finddupe_20.ps1 | function Get-SHA512([System.IO.FileInfo] $file = $(throw 'Usage: Get-MD5 [System.IO.FileInfo]'))
{
$stream = $null;
$cryptoServiceProvider = [System.Security.Cryptography.SHA512CryptoServiceProvider];
$hashAlgorithm = new-object $cryptoServiceProvider
$stream = $file.OpenRead();
$hashByteArray = $h... |
PowerShellCorpus/PoshCode/Add EventLogs to Mongo.ps1 | Add EventLogs to Mongo.ps1 | <#
.NOTES
AUTHOR: Sunny Chakraborty(sunnyc7@gmail.com)
WEBSITE: http://tekout.wordpress.com
CREATED: 8/20/2012
Requires:
a) PowerShell v2 or better
b) Requires Mongo Official C# driver
https://github.com/mongodb/mongo-csharp-driver/downloads
Tested using 1.5.0.X
c) Thanks to Justin Dearing for this:
https:... |
PowerShellCorpus/PoshCode/get-SQLInstanceInfo_1.ps1 | get-SQLInstanceInfo_1.ps1 | function get-SQLInstanceInfo2
{
param
(
[Parameter(Mandatory=$True)][string]$ComputerName
)
$InstanceInfos = @()
$Instances = (new-object 'microsoft.sqlserver.management.smo.Wmi.ManagedComputer' "$ComputerName").Services | where-object{$_.type -eq 'SqlServer'}
foreach($Instance in $Instances )... |
PowerShellCorpus/PoshCode/Get-CalendarWeek.ps1 | Get-CalendarWeek.ps1 | # Get-CalendarWeek by Holger Adam
# Simple function to retrieve the calendar week to a given or the current date.
# The function always assumes a calendar week rule of at least four days and the week starting with monday.
function Get-CalendarWeek {
param(
$Date
)
# check date input
if ($Date -eq $nu... |
PowerShellCorpus/PoshCode/Get-LogicalDiskInfo.ps1 | Get-LogicalDiskInfo.ps1 | # ========================================================================
#
# NAME: Get-LogicalDiskInfo.ps1
#
# AUTHOR: Alex Ocampo , Daptiv Solutions LLC
# DATE : 7/19/2011
#
# COMMENT: Using WMI, script check logical disk information of a single
# server or a group of servers. Script send email notificat... |
PowerShellCorpus/PoshCode/Kill Outlook + CopyPST_1.ps1 | Kill Outlook + CopyPST_1.ps1 | $rep_du_user = $env:userprofile
$repertoire_pst = ($rep_du_user+"\\AppData\\Local\\Microsoft\\Outlook")
$repertoire_sauvegarde = "directory"
#Kill de outlook
Get-Process | Where { $_.Name -Eq "outlook" } | stop-process
#wait and see :)
sleep 10
#copy des pst
xcopy $repertoire_pst $repertoire_sauvegarde /D... |
PowerShellCorpus/PoshCode/Expand-Alias 2.0.ps1 | Expand-Alias 2.0.ps1 | #requires -version 2.0
## ResolveAlias Module v2.0
########################################################################################################################
## Version History
## 1.0 - First Version. "It worked on my sample script"
## 1.1 - Now it parses the $(...) blocks inside strings
## 1.2 - So... |
PowerShellCorpus/PoshCode/Get-Weather 2.2.ps1 | Get-Weather 2.2.ps1 | #require -version 2.0
#require -shellid PoshConsole
###################################################################################################
## Get-Weather
## Parse and display the current weather and forecast from yahoo RSS
## Note that you _could_ modify this a bit to return "current condition" and "... |
PowerShellCorpus/PoshCode/Deleted-Folders.ps1 | Deleted-Folders.ps1 | function Deleted-Folders(){
param (
$Computer,
[String[]]$SeachFoldersDeleted
)
$Info = $null
$Disks = $null
trap {Write-Host "Error WmiObject $Computer";Continue}
$Disks += Get-WmiObject win32_logicaldisk -ComputerName $Computer |
Where-Object {$_.Size -ne $null}
foreach ($Disk in $Disks){
if... |
PowerShellCorpus/PoshCode/Compare-TwitterNames.ps1 | Compare-TwitterNames.ps1 | #This script will compare the names of the people you follow on Twitter
#and the people following you. It returns a comparison object consisting
#of the Twitter name of a subject and a side indicator -
#"<=" means that you are following a subject who is not following you,
#"=>" means that you are followed by so... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.