full_path
stringlengths 31
232
| filename
stringlengths 4
167
| content
stringlengths 0
48.3M
|
|---|---|---|
PowerShellCorpus/GithubGist/josheinstein_3145560_raw_5852528618a71e6c24856a4a609f9702b96cf68c_New-Password.ps1
|
josheinstein_3145560_raw_5852528618a71e6c24856a4a609f9702b96cf68c_New-Password.ps1
|
[CmdletBinding(DefaultParameterSetName='Normal')]
param(
[Parameter()]
[Int32]$Length = 8,
[Parameter(ParameterSetName="Complex")]
[Switch]$Complex,
[Parameter(ParameterSetName="Easy")]
[Switch]$Easy
)
begin {
$Upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
$Lower = 'abcdefghijklmnopqrstuvwxyz'
$Digits = '01234567890'
$Special = '~!@#$%^&*()-_+=/\.'
$RandomGen = New-Object System.Random
}
process {
$Password = ''
switch ($PSCmdlet.ParameterSetName) {
'Easy' {
$Password += $Upper[$RandomGen.Next($Upper.Length)]
while ($Password.Length -lt ($Length / 2)) {
$Password += $Lower[$RandomGen.Next($Lower.Length)]
}
while ($Password.Length -lt $Length) {
$Password += $Digits[$RandomGen.Next($Digits.Length)]
}
}
'Normal' {
$CharSet = "$Upper$Lower$Digits$Digits$Digits"
while ($Password.Length -lt $Length) {
$Password += $CharSet[$RandomGen.Next($CharSet.Length)]
}
}
'Complex' {
$CharSet = "$Upper$Lower$Digits$Digits$Digits$Special$Special$Special"
while ($Password.Length -lt $Length) {
$Password += $CharSet[$RandomGen.Next($CharSet.Length)]
}
}
}
Return $Password
}
|
PowerShellCorpus/GithubGist/togakangaroo_3318552_raw_5d4d2965bf2203ad0f3e18e4c41f0a29e5728f4c_gistfile1.ps1
|
togakangaroo_3318552_raw_5d4d2965bf2203ad0f3e18e4c41f0a29e5728f4c_gistfile1.ps1
|
New-PSDrive HOST -PSProvider FileSystem -Root \\VBOXSVR\georgemauer
$tempDir = ([system.io.path]::GetTempPath())
function edit
{
param( [Parameter(ValueFromPipeline=$true,Position=0)] $file )
begin { set-alias EDITOR 'W:\tools\sublime_text.bat' }
process { EDITOR $file }
}
function Coalesce-Args {
(@($args | ?{$_}) + $null)[0]
}
Set-Alias ?? Coalesce-Args
Set-Alias nuget W:\tools\NuGet.exe
set-alias hgworkbench 'C:\Program Files\TortoiseHg\thg.exe'
set-alias coffee W:\tools\CoffeeSharp\Coffee.exe
function Find-File([string]$pattern="*", $startAt=".") {
return Get-ChildItem $startAt -Recurse -Include $pattern
}
function Find-InFile([string]$searchFor=1, $filePattern="*", $startAt=".") {
$found = Find-File -pattern $filePattern -startAt $startAt | Select-String $searchFor
if($found -eq $null) {
Write-Host "No files found"
return
}
if($found.Count) { # There is more than one
do {
Write-Host "Please select file (Ctrl+C to quit)"
for($i=0;$i -lt $found.Count;$i=$i+1) { Write-Host "($i) - $($found[$i])" }
$idx = Read-Host
$selected = $found[$idx]
}until($selected)
}
else { $selected = $found }
edit "$($selected.Path):$($selected.LineNumber)"
}
function Open-CurrentVsd {
pushd .
cd '\\VBOXSVR\gmauer\Dropbox\Preso Builder\Bill Manager'
$curr = ls 'BM*.vsd' | sort LastWriteTime -Descending | select -First 1
#cp $curr c:\temp
#cd c:\temp
#ii $curr.Name
ii $curr
popd
}
function Open-Solution([string]$path = ".") {
$sln_files = Get-ChildItem $path -Include *.sln -Recurse
if($sln_files -eq $null) {
Write-Host "No Solution file found"
return
}
if($sln_files.Count) { # There is more than one
do {
Write-Host "Please select file (or Ctrl+C to quit)"
for($i=0;$i -lt $sln_files.Count;$i=$i+1) { Write-Host "($i) - $($sln_files[$i])" }
$idx = Read-Host
$sln = $sln_files[$idx]
}until($sln)
}
else { $sln = $sln_files }
Invoke-Item $sln
}
function Start-Cassini([string]$physical_path=((@(Coalesce-Args (Find-File Global.asax).DirectoryName "."))[0]), [int]$port=12372, [switch]$dontOpenBrowser) {
$serverLocation = Resolve-Path "C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\WebDev.WebServer40.EXE";
$full_app_path = Resolve-Path $physical_path
$url = "http://localhost:$port"
&($serverLocation.Path) /port:$port /path:"""$($full_app_path.Path)"""
Write-Host "Started $($full_app_path.Path) on $url"
Write-Host "Remember you can kill processes with kill -name WebDev*"
if($dontOpenBrowser -eq $false) {
[System.Diagnostics.Process]::Start($url)
}
}
function Remove-Trash(
[Parameter(Position=0, Mandatory=$false)][string]$Drive = "",
[switch]$NoConfirmation,
[switch]$NoProgressGui,
[switch]$NoSound
) {
add-type @"
using System;
using System.Runtime.InteropServices;
using Microsoft.Win32;
namespace recyclebin
{
public class Empty
{
[DllImport("shell32.dll")]
static extern int SHEmptyRecycleBin(IntPtr hWnd, string pszRootPath, uint dwFlags);
public static void EmptyTrash(string RootDrive, uint Flags)
{
SHEmptyRecycleBin(IntPtr.Zero, RootDrive, Flags);
}
}
}
"@
[int]$Flags = 0
if ( $NoConfirmation ) { $Flags = $Flags -bor 1 }
if ( $NoProgressGui ) { $Flags = $Flags -bor 2 }
if ( $NoSound ) { $Flags = $Flags -bor 4 }
[recyclebin.Empty]::EmptyTrash($RootPath, $Flags)
}
set-alias sudo w:/tools/sudo.ps1
set-alias msbuild C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
###################################################################
New-PSDrive PB -PSProvider FileSystem -Root W:\Surge\ErwinPenland\EpDigitalSystems.PresentationViewer\Android\PresentationViewer
set-alias adb 'C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe'
function Invoke-AsAdmin($file) {
sudo powershell (Resolve-Path $file)
}
function Update-SurgeRepos() {
pushd .
cd w:/Nen/
hg pull -u
cd w:/surge/Surge
hg pull -u
cd w:/surge/ErwinPenland
hg pull -u
cd w:/surge/PresentationBuilder
hg pull -u
popd
}
|
PowerShellCorpus/GithubGist/mikebuchanon_dc6a9a9ba39d5a9842da_raw_fbf162e8e0e7255fc49392360e23d80623d681ea_list-sessions.ps1
|
mikebuchanon_dc6a9a9ba39d5a9842da_raw_fbf162e8e0e7255fc49392360e23d80623d681ea_list-sessions.ps1
|
clear
$regpath = "HKCU:\Software\SimonTatham\PuTTY\Sessions"
$sessions = gci -path $regpath
foreach($session in $sessions){
$fixedsession = $session -replace 'HKEY_CURRENT_USER','HKCU:'
$sessionname = Split-Path $fixedsession -Leaf
Write-Host $($sessionname -replace 'RS:|%20|.public.','') `t`t $(Get-ItemProperty -path $fixedsession).HostName
}
|
PowerShellCorpus/GithubGist/glassdfir_24000caf48726ed84a5a_raw_6e65509695de933871309b6e5d9a59123273acad_livemap.ps1
|
glassdfir_24000caf48726ed84a5a_raw_6e65509695de933871309b6e5d9a59123273acad_livemap.ps1
|
[CmdletBinding(PositionalBinding=$false)]
Param(
[Parameter(Mandatory=$False)]
[String] $Remote =""
)
$global:outputlines = @()
$outfile = "liveprocessmap.html"
$ComputerName="LocalHost"
$Header = "<script src="https://www.google.com/jsapi" type="text/javascript"></script><script type="text/javascript">// <![CDATA[
google.load('visualization', '1', {packages:['orgchart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'ProcessID');
data.addColumn('string', 'Label');
data.addColumn('string', 'ToolTip');
data.addRows([
"
$Header| Out-File $outfile
If($Remote=""){$ComputerName = $Remote}
$RunningProcesses = Get-WmiObject win32_process -ComputerName $ComputerName| select ProcessID,ParentProcessID,name,commandline
ForEach($RunningProcess in $RunningProcesses){
$processID = $RunningProcess.ProcessID
$parentprocessID = $RunningProcess.ParentProcessID
$processname = $RunningProcess.Name
$commandline = $RunningProcess.CommandLine -replace "`'",""
$commandline = $commandline -replace '"',""
$OutLine = "[{v:'" + $processID + "', f:'" + $processID + "<div>" + $processname + "</div>'},'" + $ParentProcessID + "','" + $commandline +"']"
$OutLine = $Outline -replace '',''
$global:outputlines+=$Outline
}
ForEach($line in $global:outputlines){
If($global:outputlines.IndexOf($line) -eq $global:outputlines.GetUpperBound(0)){ $comma = " " } Else { $comma = ","}
$line + $comma | Add-Content $outfile
}
$footer = "]);
var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));
chart.draw(data, {allowHtml:true,allowCollapse:true});
}
// ]]></script>
</head>
<body>
<div id=`'chart_div`'></div>
</body>
</html>
"
$footer| Add-Content $outfile
|
PowerShellCorpus/GithubGist/rysstad_a24dc630df295dffd32a_raw_ec5569be390cbd2ec9466d74e6927c598c3b0733_Get-ProsentageThePowershellWay.ps1
|
rysstad_a24dc630df295dffd32a_raw_ec5569be390cbd2ec9466d74e6927c598c3b0733_Get-ProsentageThePowershellWay.ps1
|
# Use tostring("P"):
$a = [math]::PI
$b = [math]::E
($a/$a).tostring("P")
|
PowerShellCorpus/GithubGist/mattsalmon_5478540_raw_050fd627679e25e2df55272ff86f178570c7943e_install.ps1
|
mattsalmon_5478540_raw_050fd627679e25e2df55272ff86f178570c7943e_install.ps1
|
#Umbraco Power shell API
#Default Nuget Params
param($installPath, $toolsPath, $package, $project)
if ($project) {
#Connect to Umbraco Services API
#Create Home DocumentType
#Create Properties on Home DocumentType
#Create TextPage DocumentType
#Create Properties on TextPage
#Set TextPage as child of Home DocType
#Create Homepage page at Root
#Fill values on homepage - save & publish
#Create child TextPage node
#fill values on TextPage - save & publish
}
|
PowerShellCorpus/GithubGist/nick-o_9219454_raw_fd929ab92b17b7afb97cc06117455a669f256faf_test_deploy.ps1
|
nick-o_9219454_raw_fd929ab92b17b7afb97cc06117455a669f256faf_test_deploy.ps1
|
Get-Process
|
PowerShellCorpus/GithubGist/trondhindenes_3fc8f394e426cefca702_raw_dae2217a218465c92de2e24475a07a57f31edcf0_PowerShell%20Workflow%20paralell%20with%20throttle%20limit.ps1
|
trondhindenes_3fc8f394e426cefca702_raw_dae2217a218465c92de2e24475a07a57f31edcf0_PowerShell%20Workflow%20paralell%20with%20throttle%20limit.ps1
|
workflow paralleltest
{
$a = 1..10
#Divide the 10 iterations into 3 (+1) blocks
foreach -parallel -throttlelimit (($a.count)/3) ($b in $a)
{
Write-Output $b
}
}
paralleltest
|
PowerShellCorpus/GithubGist/kujotx_5462869_raw_49b682b60b1579e3ecb00334a0f4c434c3606cd4_gistfile1.ps1
|
kujotx_5462869_raw_49b682b60b1579e3ecb00334a0f4c434c3606cd4_gistfile1.ps1
|
Write-Host "Create the fake file"
$file = New-Item C:\temp\sillytest\new_file.txt -type file -force -value "__NAME__"
Write-Host "Change to that directory"
Set-Location "c:\temp\sillytest"
Write-Host "Make it read only"
sp $file IsReadOnly 1
Write-Host "Add the template folder"
warmup addTemplateFolder sillytest "c:\temp\sillytest"
Write-Host "Apply warmup template"
Set-Location "c:\temp"
warmup sillytest GOOFBALL
Write-Host "Your new_file.txt still has __NAME__ in it"
|
PowerShellCorpus/GithubGist/mhinze_e65789ed26107038072c_raw_98cdfc915d98da6f93b24416ea3a4d748e7ea444_Disable-NServiceBusSetupCheck.ps1
|
mhinze_e65789ed26107038072c_raw_98cdfc915d98da6f93b24416ea3a4d748e7ea444_Disable-NServiceBusSetupCheck.ps1
|
function global:Disable-NServiceBusSetupCheck()
{
#default to current dir when debugging
if(!$solutionScriptsContainer){
$solutionScriptsContainer = "./"
}
$packagesFolder = Join-Path $solutionScriptsContainer "..\packages" -Resolve
Push-Location $packagesFolder
# Load NSB powershell module
$nsbPowerShellPath = Get-ChildItem . -Recurse -Filter NServiceBus.PowerShell.dll | Select-Object -First 1
if (Get-Module NServiceBus.Powershell) {
Remove-Module NServiceBus.Powershell
}
Import-Module ($nsbPowerShellPath.FullName)
# Setup registry variables
$nserviceBusKeyPath = "HKCU:SOFTWARE\NServiceBus"
$machinePreparedKey = "MachinePrepared"
$dontCheckMachineSetupKey = "DontCheckMachineSetup"
$machinePrepared = $false
$nservicebusVersion = Get-NServiceBusVersion
$nserviceBusVersionPath = $nserviceBusKeyPath + "\" + $nservicebusVersion.Major + "." + $nservicebusVersion.Minor
# If NSB registry entries are missing for the current version, then create them. There is an issue in the current script where this is broken.
if (!(Test-Path $nserviceBusKeyPath)) {
New-Item -Path HKCU:SOFTWARE -Name NServiceBus | Out-Null
}
if (!(Test-Path $nserviceBusVersionPath)){
$versionToAdd = "$($nservicebusVersion.Major).$($nservicebusVersion.Minor)"
New-Item -Path $nserviceBusKeyPath -Name $versionToAdd | Out-Null
New-ItemProperty -Path $nserviceBusVersionPath -Name $machinePreparedKey -PropertyType String -Value "false" | Out-Null
New-ItemProperty -Path $nserviceBusVersionPath -Name $dontCheckMachineSetupKey -PropertyType String -Value "true" | Out-Null
}
else {
# If NSB registry entries are present, ensure setup check is disabled.
$a = Get-ItemProperty -path $nserviceBusVersionPath
$dontCheckMachineSetup = $a.psobject.properties | ?{ $_.Name -eq $dontCheckMachineSetupKey }
# Only set the registry entry if it is not already there. This allows users to still turn the check on if they choose.
if(!$dontCheckMachineSetup) {
New-ItemProperty -Path $nserviceBusVersionPath -Name $dontCheckMachineSetupKey -PropertyType String -Value "true" | Out-Null
}
}
Pop-Location
}
Disable-NServiceBusSetupCheck
|
PowerShellCorpus/GithubGist/alanrenouf_be6342791941f9531cf5_raw_5e2b47d1b3a00e1cab36a83ab8ea08516ce65541_NatRules.ps1
|
alanrenouf_be6342791941f9531cf5_raw_5e2b47d1b3a00e1cab36a83ab8ea08516ce65541_NatRules.ps1
|
Function New-DNATRule (
$EdgeGateway,
$ExternalNetwork,
$OriginalIP,
$OriginalPort,
$TranslatedIP,
$TranslatedPort,
$Protocol) {
$Edgeview = Search-Cloud -QueryType EdgeGateway -name $EdgeGateway | Get-CIView
if (!$Edgeview) {
Write-Warning "Edge Gateway with name $Edgeview not found"
Exit
}
$URI = ($edgeview.Href + "/action/configureServices")
$wc = New-Object System.Net.WebClient
# Add Authorization headers
$wc.Headers.Add("x-vcloud-authorization", $Edgeview.Client.SessionKey)
$wc.Headers.Add("Content-Type", "application/vnd.vmware.admin.edgeGatewayServiceConfiguration+xml")
$wc.Headers.Add("Accept", "application/*+xml;version=5.1")
$webclient = New-Object system.net.webclient
$webclient.Headers.Add("x-vcloud-authorization",$Edgeview.Client.SessionKey)
$webclient.Headers.Add("accept",$EdgeView.Type + ";version=5.1")
[xml]$EGWConfXML = $webclient.DownloadString($EdgeView.href)
[xml]$OriginalXML = $EGWConfXML.EdgeGateway.Configuration.EdgegatewayServiceConfiguration.NatService.outerxml
$NewID = [int]($OriginalXML.NatService.natrule | Sort-Object id | Select-Object Id -Last 1).id + 1
If($NewID -eq 1){
$NewID = 65537
}
$strXML = '<NatRule>
<RuleType>DNAT</RuleType>
<IsEnabled>true</IsEnabled>
<Id>' + $NewID + '</Id>
<GatewayNatRule>
<Interface type="application/vnd.vmware.admin.network+xml" name="' + $ExternalNetwork.Name + '" href="' + $ExternalNetwork.Href + '"/>
<OriginalIp>' + $OriginalIP + '</OriginalIp>
<OriginalPort>' + $OriginalPort + '</OriginalPort>
<TranslatedIp>' + $TranslatedIP + '</TranslatedIp>
<TranslatedPort>' + $TranslatedPort + '</TranslatedPort>
<Protocol>' + $Protocol + '</Protocol>
</GatewayNatRule>
</NatRule>'
$GoXML = '<?xml version="1.0" encoding="UTF-8"?>
<EdgeGatewayServiceConfiguration xmlns="http://www.vmware.com/vcloud/v1.5" >
<NatService>
<IsEnabled>true</IsEnabled>'
$OriginalXML.NatService.NatRule | ForEach-Object {
$GoXML += $_.OuterXML
}
$GoXML += $StrXML
$GoXML += '</NatService>
</EdgeGatewayServiceConfiguration>'
[byte[]]$byteArray = [System.Text.Encoding]::ASCII.GetBytes($GoXML)
$UploadData = $wc.Uploaddata($URI, "POST", $bytearray)
}
Function New-SNATRule (
$EdgeGateway,
$ExternalNetwork,
$OriginalIP,
$OriginalPort,
$TranslatedIP,
$TranslatedPort,
$Protocol) {
$Edgeview = Search-Cloud -QueryType EdgeGateway -name $EdgeGateway | Get-CIView
if (!$Edgeview) {
Write-Warning "Edge Gateway with name $Edgeview not found"
Exit
}
$URI = ($edgeview.Href + "/action/configureServices")
$wc = New-Object System.Net.WebClient
$wc.Headers.Add("x-vcloud-authorization", $Edgeview.Client.SessionKey)
$wc.Headers.Add("Content-Type", "application/vnd.vmware.admin.edgeGatewayServiceConfiguration+xml")
$wc.Headers.Add("Accept", "application/*+xml;version=5.1")
$webclient = New-Object system.net.webclient
$webclient.Headers.Add("x-vcloud-authorization",$Edgeview.Client.SessionKey)
$webclient.Headers.Add("accept",$EdgeView.Type + ";version=5.1")
[xml]$EGWConfXML = $webclient.DownloadString($EdgeView.href)
[xml]$OriginalXML = $EGWConfXML.EdgeGateway.Configuration.EdgegatewayServiceConfiguration.NatService.outerxml
$NewID = [int]($OriginalXML.NatService.natrule | Sort-Object id | Select-Object Id -Last 1).id + 1
If($NewID -eq 1){
$NewID = 65537
}
$strXML = '<NatRule>
<RuleType>SNAT</RuleType>
<IsEnabled>true</IsEnabled>
<Id>' + $NewID + '</Id>
<GatewayNatRule>
<Interface type="application/vnd.vmware.admin.network+xml" name="' + $ExternalNetwork.Name + '" href="' + $ExternalNetwork.Href + '"/>
<OriginalIp>' + $OriginalIP + '</OriginalIp>
<TranslatedIp>' + $TranslatedIP + '</TranslatedIp>
</GatewayNatRule>
</NatRule>'
$GoXML = '<?xml version="1.0" encoding="UTF-8"?>
<EdgeGatewayServiceConfiguration xmlns="http://www.vmware.com/vcloud/v1.5" >
<NatService>
<IsEnabled>true</IsEnabled>'
$OriginalXML.NatService.NatRule | ForEach-Object {
$GoXML += $_.OuterXML
}
$GoXML += $StrXML
$GoXML += '</NatService>
</EdgeGatewayServiceConfiguration>'
[byte[]]$byteArray = [System.Text.Encoding]::ASCII.GetBytes($GoXML)
$UploadData = $wc.Uploaddata($URI, "POST", $bytearray)
}
Function Get-EdgeNATRule ($EdgeGateway) {
$Edgeview = Search-Cloud -QueryType EdgeGateway -name $EdgeGateway | Get-CIView
if (!$Edgeview) {
Write-Warning "Edge Gateway with name $Edgeview not found"
Exit
}
$webclient = New-Object system.net.webclient
$webclient.Headers.Add("x-vcloud-authorization",$Edgeview.Client.SessionKey)
$webclient.Headers.Add("accept",$EdgeView.Type + ";version=5.1")
[xml]$EGWConfXML = $webclient.DownloadString($EdgeView.href)
$NATRules = $EGWConfXML.EdgeGateway.Configuration.EdgegatewayServiceConfiguration.NatService.Natrule
$Rules = @()
if ($NATRules){
$NATRules | ForEach-Object {
$NewRule = new-object PSObject -Property @{
AppliedOn = $_.GatewayNatRule.Interface.Name;
Type = $_.RuleType;
OriginalIP = $_.GatewayNatRule.OriginalIP;
OriginalPort = $_.GatewayNatRule.OriginalPort;
TranslatedIP = $_.GatewayNatRule.TranslatedIP;
TranslatedPort = $_.GatewayNatRule.TranslatedPort;
Enabled = $_.IsEnabled;
Protocol = $_.GatewayNatRule.Protocol
}
$Rules += $NewRule
}
}
$Rules
}
# Example of using the functions
Get-EdgeNATRule -EdgeGateway "TEstEG"
New-SNATRule -EdgeGateway "TEstEG" -ExternalNetwork (Get-ExternalNetwork "Test") -OriginalIP "10.0.0.53" -TranslatedIP "192.168.1.53"
New-DNATRule -EdgeGateway "TEstEG" -ExternalNetwork (Get-ExternalNetwork "Test") -OriginalIP "192.168.1.52" -OriginalPort "any" -TranslatedIP "10.0.0.3" -TranslatedPort "any" -Protocol "tcp"
|
PowerShellCorpus/GithubGist/SimonWahlin_3c69d10a1c13aa439063_raw_9aa5754a4589660c7192f8272c8be75d0f6cdd62_gistfile1.ps1
|
SimonWahlin_3c69d10a1c13aa439063_raw_9aa5754a4589660c7192f8272c8be75d0f6cdd62_gistfile1.ps1
|
Function Init {
$File = "$env:tmp\testfile.tmp"
if(-Not (Test-Path -Path $File)){[Void](New-Item -Path $File -Type File)}
Start-Service -Name Spooler
}
Function Validate {
$File = "$env:tmp\testfile.tmp"
$FileStatus = if(Test-Path -Path $File){'Exists'}else{'Removed'}
$SrvStatus = (Get-Service -Name Spooler).Status
'{0,-7} {1}'-f $FileStatus, $SrvStatus
}
Function Measureit {
$File = "$env:tmp\testfile.tmp"
Init
$m1 = (Measure-Command -Expression {
Stop-Service -Name Spooler -Force |
Remove-Item $File |
Start-Service -Name Spooler
}).milliseconds
$r1 = Validate
$m2 = (Measure-Command -Expression {
Stop-Service -Name Spooler -Force
Remove-Item $File
Start-Service -Name Spooler
}).Milliseconds
$r2 = Validate
"Time:{0,-4}Result: {1,-17} | Time:{2,-4}Result: {3,-20}" -f $m1, $r1, $m2, $r2
}
1..20 | %{measureit}
|
PowerShellCorpus/GithubGist/GraemeF_1116727_raw_00be82e1b9c4828bae24869d6e883d00793a9980_RestorePackages.ps1
|
GraemeF_1116727_raw_00be82e1b9c4828bae24869d6e883d00793a9980_RestorePackages.ps1
|
# Tools
.\NuGet.exe i DotCover -s \\myserver\Dev\NuGetPackages -o Tools
.\NuGet.exe i StyleCopCmd -s \\myserver\Dev\NuGetPackages -o Tools
# Dependecies
$packageConfigs = Get-ChildItem . -Recurse | where{$_.Name -eq "packages.config"}
foreach($packageConfig in $packageConfigs){
Write-Host "Restoring" $packageConfig.FullName
nuget i $packageConfig.FullName -o Packages
}
|
PowerShellCorpus/GithubGist/sunnyc7_4478200_raw_3b898e1be617ee56f52aabbd166bd5122de80ada_get-2010sg.ps1
|
sunnyc7_4478200_raw_3b898e1be617ee56f52aabbd166bd5122de80ada_get-2010sg.ps1
|
#Original Doug Finke's gist - https://gist.github.com/4467657
#download all scripting games code by Rohn Edwards
$url="http://2012sg.poshcode.org/Scripts/By/862"
(Invoke-WebRequest $url).links | where{$_.innerHTML -eq "Download"} | ForEach {
$outFile = "c:\temp\$($_.outerText)"
#"Downloading $($_.InnerHtml) -> $($outFile)"
$callstring = "http://2012sg.poshcode.org"+$_.href
$callstring
Invoke-WebRequest $callstring -OutFile $outFile
}
#>
<#
Doug Finke Script Mod.
Take the URL
for each URL.Links get links which are -like 2012sg.poshcode.org/number
populate that into an array
for each member in the array
call 2012sg.poshcode.org/Scripts/Get/ The number
Script is not generating the files as 4567.ps1. Will check this later.
#>
|
PowerShellCorpus/GithubGist/tckz_135053_raw_5bbdc8883de262930e9e6663742cccabf37a64d7_report_wsus.ps1
|
tckz_135053_raw_5bbdc8883de262930e9e6663742cccabf37a64d7_report_wsus.ps1
|
param([switch]$nomail)
trap [Exception] {
$t = $error[0].ToString().Trim() + "`n" + $error[0].InvocationInfo.PositionMessage.Trim()
[Diagnostics.EventLog]::WriteEntry("report_wsus", $t, "Error", 1)
}
[reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | out-null
$update_server = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer()
$update_server.PreferredCulture ="ja"
$email_conf = $update_server.GetEmailNotificationConfiguration()
$update_scope = new-object Microsoft.UpdateServices.Administration.UpdateScope
$allComputersGroup = $update_server.GetComputerTargetGroup([Microsoft.UpdateServices.Administration.ComputerTargetGroupId]::AllComputers)
$classifications_text = ""
foreach($guid in @(
# Service Packs
"68c5b0a3-d1a6-4553-ae49-01d3a7827828",
# セキュリティ問題の修正プログラム
"0fa1201d-4330-4fa8-8ae9-b877473b6441",
# 修正プログラム集
"28bc880e-0592-4cbf-8f95-c79b17911d5f",
# 重要な更新
"e6cf1350-c01b-414d-a61f-263d14d133b4"
))
{
$classification = $update_server.GetUpdateClassification((New-Object System.Guid($guid)))
$classifications_text += [string]::Format("`t{0}`n", $classification.Title)
$ret = $update_scope.Classifications.Add($classification)
}
# IComputerTarget.Id => IComputerTarget
$bad_computers = @{}
$body = ""
$dt_start = [System.DateTime]::Now
# 更新に対する条件
$update_scope.ApprovedStates =
[Microsoft.UpdateServices.Administration.ApprovedStates]::LatestRevisionApproved -bor
[Microsoft.UpdateServices.Administration.ApprovedStates]::HasStaleUpdateApprovals
$update_scope.IncludedInstallationStates =
[Microsoft.UpdateServices.Administration.UpdateInstallationStates]::Unknown -bor
[Microsoft.UpdateServices.Administration.UpdateInstallationStates]::NotInstalled -bor
[Microsoft.UpdateServices.Administration.UpdateInstallationStates]::InstalledPendingReboot -bor
[Microsoft.UpdateServices.Administration.UpdateInstallationStates]::Failed -bor
[Microsoft.UpdateServices.Administration.UpdateInstallationStates]::Downloaded
# コンピュータに対する条件
$computer_scope = new-object Microsoft.UpdateServices.Administration.ComputerTargetScope
$computer_scope.IncludedInstallationStates = $update_scope.IncludedInstallationStates
foreach($summary in $update_server.GetSummariesPerComputerTarget($update_scope, $computer_scope))
{
$computer = $update_server.GetComputerTarget($summary.ComputerTargetId)
$id = $computer.Id.ToString()
$bad_computers[$id] = $computer
}
$body += [string]::Format("検索時間:{0}`n", [System.DateTime]::Now.Subtract($dt_start).ToString())
if($bad_computers.Count -eq 0)
{
exit
}
$body += @"
対象更新クラス:
$classifications_text
コンピュータ:
"@
$searcher = New-Object DirectoryServices.DirectorySearcher
foreach($computer in $bad_computers.values | sort FullDomainName)
{
$manage_cn = ""
$computer_account = $computer.FullDomainName.Split(".")[0] + '$'
$searcher.Filter = "(sAMAccountName=$computer_account)"
$result = $searcher.FindOne()
if($result -ne $null)
{
$managed_by = $result.Properties["managedby"]
$r = New-Object Text.RegularExpressions.Regex("CN=([^,]+)")
$m = $r.Match($managed_by)
if($m.Success)
{
$manage_cn = $m.Groups[1].Captures[0]
}
}
$v = $computer.OSInfo.Version
$a = @(
$computer.FullDomainName,
$computer.IPAddress.ToString(),
$computer.LastReportedStatusTime.ToLocalTime().ToString(),
$manage_cn,
$computer.Make.Trim(),
$computer.Model.Trim(),
$computer.OSArchitecture.Trim(),
$computer.OSDescription.Trim(),
[string]::Join(".", @($v.Major, $v.Minor, $v.Build)),
[string]::Join(".", @($v.ServicePackMajor, $v.ServicePackMinor))
)
$body +=[string]::Join("`t", $a) + "`n"
}
$mail = New-Object System.Net.Mail.SmtpClient($email_conf.SmtpHostName)
$mail.Timeout = 30 * 1000
$msg = New-Object System.Net.Mail.MailMessage
$msg.Subject = "[WSUS]更新未適用コンピュータ"
$msg.From = New-Object System.Net.Mail.MailAddress($email_conf.SenderEmailAddress, $email_conf.SenderDisplayName)
foreach($rcpt in $email_conf.StatusNotificationRecipients)
{
$msg.To.Add($rcpt)
}
$msg.Body = $body
if($nomail)
{
write-host $body
}
else
{
$mail.Send($msg)
}
|
PowerShellCorpus/GithubGist/n-fukuju_8499843_raw_9acd8d87cb0be6258c7ff1ff857dc17f7964399a_form.ps1
|
n-fukuju_8499843_raw_9acd8d87cb0be6258c7ff1ff857dc17f7964399a_form.ps1
|
[void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$form = New-Object System.Windows.Forms.Form
$form.StartPosition = [Windows.Forms.FormStartPosition]::CenterScreen
$button = New-Object System.Windows.Forms.Button
$button.Text = "Exit"
$button.Add_Click({ $form.Close() }) # <= これ
$form.Controls.Add($button)
$form.ShowDialog()
|
PowerShellCorpus/GithubGist/bohrshaw_8252232_raw_e9bdc42752102a8f471be399565063a7498a225a_python-virtualenv-install.ps1
|
bohrshaw_8252232_raw_e9bdc42752102a8f471be399565063a7498a225a_python-virtualenv-install.ps1
|
# http://stackoverflow.com/questions/4750806/how-to-install-pip-on-windows
# Download files
Invoke-WebRequest -OutFile ez_setup.py https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
Invoke-WebRequest -OutFile get_pip.py https://raw.github.com/pypa/pip/master/contrib/get-pip.py
# Installing
python ez_setup.py
python get_pip.py
# Remove downloaded files
rm ez_setup.py,get_pip.py,setuptools-*
# Add C:\Python27\Scripts to PATH
|
PowerShellCorpus/GithubGist/mwrock_5422718_raw_85a5f4e61328557b78bdb5ec9cd6e38ce0add6a6_gistfile1.ps1
|
mwrock_5422718_raw_85a5f4e61328557b78bdb5ec9cd6e38ce0add6a6_gistfile1.ps1
|
Add-Type -AssemblyName System.IO.Compression.FileSystem,System.IO.Compression
$here= (Get-Item .).FullName
$archive = [System.IO.Compression.ZipFile]::Open(
(Join-Path $here "archive.zip"), [System.IO.Compression.ZipArchiveMode]::Create
)
get-tfsPendingChange | % {
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile(
$archive, $_.LocalItem, $_.LocalItem.Substring($here.Length+1)
)
}
$archive.Dispose()
|
PowerShellCorpus/GithubGist/seankearney_4019944_raw_791096a32da5c4eae0991ec9271cc40332b25529_archiveLogs.ps1
|
seankearney_4019944_raw_791096a32da5c4eae0991ec9271cc40332b25529_archiveLogs.ps1
|
##################################################################
# IIS Web Log Archive Script
# Takes a path to a directory containing IIS Log files
# Zips them up with 7-zip and stores the zip in a
# directory multiple levels up.
# Original log files are then deleted
#
# Expected folder structures:
# X:\Some\Directory\ContainAllLogs\
# |- Live
# |- Domain Name [server.com]
# |- Subdomain [www] ** This is the path that IIS is configured with
# |- IIS Auto Created folder [w3svcxxxxxx]
# |- Archive
# |- Domain Name [server.com]
# |- Subdomain [www] ** This is where the zip will go
#
# Usage:
# Within a .bat file:
#
# powershell set-executionpolicy Unrestricted
# REM -- *.ashfordapps.com
# powershell "& .\archiveLogs.ps1 "X:\WebsiteLogs\Live\Domain.com\Subdomain\W3SVC286639526" "
#
##################################################################
param (
$logPath = $(throw 'Please supply a path to the log files'),
$zipPrefix = ""
)
#$logPath = "C:\test\Logs"
$month = [DateTime]::Today.AddMonths(-1).ToString("MM")
$year = [DateTime]::Today.AddMonths(-1).ToString("yy")
$zipName = ($zipPrefix + "ex" + $year + $month + ".zip")
$searchString = ("ex" + $year + $month + "*.log")
$searchString = [System.IO.Path]::Combine($logPath, $searchString)
$count = 0
$List = @(Get-ChildItem $searchString)
# Check number of files and exit if 0
foreach ($_ in $List ){$_.name
$count = $count +1}
if ($count -eq 0){
return
}
# Build archive path
$domainName = (Get-Item $logPath).Parent.Parent.Name
$subDomainName = (Get-Item $logPath).Parent.Name
# Get the root archive path
# We are at: X:\somepath\Live\[Domain]\[SubDomain]\[auto]
# We want it at: X:\somepath\Archive\[Domain]\[SubDomain]
# X:\somepath\
$archivePath = (Get-Item $logPath).Parent.Parent.Parent.Parent.Fullname
# Tack on the 'Archive' directory
$archivePath = [System.IO.Path]::Combine($archivePath, "Archive")
# Tack on the 'Domain' directory
$archivePath = [System.IO.Path]::Combine($archivePath, $domainName)
# Tack on the 'SubDomain' directory
$archivePath = [System.IO.Path]::Combine($archivePath, $subDomainName)
# Create the directory for the archive
[System.IO.Directory]::CreateDirectory($archivePath) | out-null
$archivePath = [System.IO.Path]::Combine($archivePath, $zipName)
# Archive the files
C:\Utils\PortableApps\7-ZipPortable\App\7-Zip\7z.exe a -tzip $archivePath $searchString
# delete all .log files
ri $searchString
|
PowerShellCorpus/GithubGist/Touichirou_67db5dfe42df11b0f514_raw_7a7c42be36f143da12a298ef289762fca344ce2a_auto-login-windows.ps1
|
Touichirou_67db5dfe42df11b0f514_raw_7a7c42be36f143da12a298ef289762fca344ce2a_auto-login-windows.ps1
|
# Enable Auto login
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "AutoAdminLogon" -Value 1
# Set Auto login user
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "DefaultUsername" -Value "vagrant"
# Set Auto login password
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "DefaultPassword" -Value "vagrant"
|
PowerShellCorpus/GithubGist/ujiro99_6258121_raw_f55a9da07946032adfb56accd3ce4d193c57e454_profile.ps1
|
ujiro99_6258121_raw_f55a9da07946032adfb56accd3ce4d193c57e454_profile.ps1
|
# 現在のユーザー名とホスト名をタイトルに
$global:currentuser = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$user_and_host = ($currentuser.name -replace "(.*?)\\(.*?)$", "`$2@`$1")
$Host.UI.RawUI.WindowTitle = $user_and_host + " - Windows PowerShell"
# プロンプトのカスタマイズ
function prompt {
write-host ""
# ディレクトリの表示 (バックスラッシュをスラッシュに変換)
$pwd = $(get-location) -replace "\\", "/"
write-host $pwd -nonewline -foregroundcolor yellow
write-host " " -nonewline
# Gitリポジトリがあった場合
if (Test-Path .git) {
$branch = $(get_git_branch_name)
# ブランチ名の表示を右寄せする
$oldposition = $host.ui.rawui.CursorPosition
$Endline = $oldposition
# 一行の行数からブラケットとブランチ名の長さを引く
$Endline.X = 120 - 2 - $branch.Length
$host.ui.rawui.CursorPosition = $Endline
if ($(get_git_status) -eq 1) {
write-host ("[" + $branch + "]") -nonewline -foregroundcolor white -backgroundcolor red
} else {
write-host ("[" + $branch + "]") -nonewline -foregroundcolor red
}
$host.ui.rawui.CursorPosition = $oldposition
}
write-host ""
return "$ "
}
# Git: ブランチ名を取得
function get_git_branch_name () {
$name = ""
git branch | foreach {
if ($_ -match "^\*(.*)"){
$name += ($matches[1] -replace "^ ", "")
}
}
return $name
}
# Git: 更新があるかどうかを取得
function get_git_status () {
$status = 1
git st | foreach {
if ($_ -match "^nothing to commit \(") {
$status = 0
}
}
return $status
}
|
PowerShellCorpus/GithubGist/janikvonrotz_8331053_raw_f4c8e58b088858dd0860e0d255c1d36e75a081bf_Replace-ADMemberGroupWithUsers.ps1
|
janikvonrotz_8331053_raw_f4c8e58b088858dd0860e0d255c1d36e75a081bf_Replace-ADMemberGroupWithUsers.ps1
|
Import-Module ActiveDirectory
Get-ADGroup -Filter * -SearchBase "OU=Projekte,OU=SharePoint,OU=Services,OU=vblusers2,DC=vbl,DC=ch" | where{$_.Name -like "SP_Projekt *"} | sort Name | %{
$Group = $_
Write-Host "Update group: $($_.Name)"
$Members = Get-ADGroupMember $_ -Recursive | select -Unique
Remove-ADGroupMember -Identity $_ -Members $(Get-ADGroupMember -Identity $_) -Confirm:$false
$Members | %{Add-ADGroupMember -Identity $Group -Members $_}
}
|
PowerShellCorpus/GithubGist/miwaniza_c00ddaf1df1554bdf0cd_raw_ea0063df07d9c4c7bae5cca427b126268b40aee2_Add-VaultUser.ps1
|
miwaniza_c00ddaf1df1554bdf0cd_raw_ea0063df07d9c4c7bae5cca427b126268b40aee2_Add-VaultUser.ps1
|
# You are already logged in Vault from Vault2014powerConsole
# So you can freely use
# $vltActiveConn.WebServiceManager.FilestoreVaultService - FileStoreService
# $vltAdminSvc - AdminService
$userName = 'AD'
$password = '12345'
$atype = 'Vault' # or 'ActiveDir'
$firstName = 'Albrecht'
$lastName = 'Dürer'
$email = 'AD@painter.com'
$isActive = $true
$roleNameArray = 'Document editor (level 2)', 'ERP Manager'
$vaultNameArray = 'Vault', 'Renaissance'
# Getting vault IDs by names
$vaultIdArray = $vltActiveConn.WebServiceManager.FilestoreVaultService.GetKnowledgeVaultsByNames($vaultNameArray).Id
# Getting roles IDs by names
$roleIdArray = ($vltAdminSvc.GetAllRoles() | Where {$roleNameArray -contains $_.Name}).Id
# Adding user
$newUser = $vltAdminSvc.AddUser($userName, $password, $atype, $firstName, $lastName, $email, $isActive, $roleIdArray, $vaultIdArray)
|
PowerShellCorpus/GithubGist/ciphertxt_5244814_raw_d96ec396d368f998dcc2d1666555b55caa20e140_GetSPFarmSolutions.ps1
|
ciphertxt_5244814_raw_d96ec396d368f998dcc2d1666555b55caa20e140_GetSPFarmSolutions.ps1
|
function Get-SPFarmSolutions {
param (
[string] $directory = $(Read-Host -prompt "Enter a directory (use ""."" for current dir)")
)
if ($directory.Length -lt 2) {
$directory = [string]$pwd + "\\";
}
$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local;
$solutions = $farm.Solutions;
$solutions | ForEach-Object {
Write-Host "Found solution $_.name";
$_.SolutionFile.SaveAs($directory + $_.name);
}
}
|
PowerShellCorpus/GithubGist/sunnyc7_11219860_raw_7a7df7f1d3fd3663b47c6ec2bc1846771a2553f7_Send-EmailMessage.ps1
|
sunnyc7_11219860_raw_7a7df7f1d3fd3663b47c6ec2bc1846771a2553f7_Send-EmailMessage.ps1
|
Function Send-EMailMessage {
[CmdletBinding()]
param(
[Parameter(Position=1, Mandatory=$true)]
[String[]]
$To,
[Parameter(Position=2, Mandatory=$false)]
[String[]]
$CcRecipients,
[Parameter(Position=3, Mandatory=$false)]
[String[]]
$BccRecipients,
[Parameter(Position=4, Mandatory=$true)]
[String]
$Subject,
[Parameter(Position=5, Mandatory=$true)]
[String]
$Body,
[Parameter(Position=6, Mandatory=$false)]
[Switch]
$BodyAsHtml,
[Parameter(Position=7, Mandatory=$true)]
[System.Management.Automation.PSCredential]
$Credential,
[Parameter(Position=8, Mandatory=$false)]
[String]$Attachment
)
begin {
#Load the EWS Managed API Assembly
#Install EWS Assembly form here and install it.
# http://www.microsoft.com/en-us/download/details.aspx?id=28952
#Copy EWS Assembly
$EwsLocalPath = "C:\Program Files\Microsoft\Exchange\Web Services\1.0"
if (!(Test-Path -Path $EwsLocalPath)) {
New-Item -ItemType Directory -Path $EwsLocalPath
Copy $EWSSharePath\*.* $EwsLocalPath
}
else {
Copy $EWSSharePath\*.* $EwsLocalPath
}
Add-Type -Path $EwsLocalPath\Microsoft.Exchange.WebServices.dll
}
process {
#Insatiate the EWS service object
$service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService -ArgumentList Exchange2010_SP1
#Set the credentials for Exchange Online
$service.Credentials = New-Object Microsoft.Exchange.WebServices.Data.WebCredentials -ArgumentList $Credential.UserName, $Credential.GetNetworkCredential().Password
#Find Email Address from UserName
$tmpUsername = ($Credential.UserName).Split("\")[1]
$query = "SELECT * FROM ds_user where ds_sAMAccountName='$tmpUsername'"
$user = Get-WmiObject -Query $query -Namespace "root\Directory\LDAP"
#Determine the EWS endpoint using autodiscover
$service.AutodiscoverUrl($user.DS_mail)
# Configure Exchange Impersonation.
# Impersonation Rights are granted by the following ROLE-ASSIGNMENT
# New-ManagementRoleAssignment –Name:EWSImpersonationTEST –Role:ApplicationImpersonation –User:"domain\svcImpersonationID"
# Remove Role Assignment
# Get-ManagementRoleAssignment -RoleAssigneeType User | Where {$_.Role -eq "ApplicationImpersonation" } | select -First 1 | Remove-ManagementRoleAssignment
# Add Impersonation
$MailboxName = "first.lastname@companydomain.com"
$service.ImpersonatedUserId = new-object Microsoft.Exchange.WebServices.Data.ImpersonatedUserId([Microsoft.Exchange.WebServices.Data.ConnectingIdType]::SmtpAddress, $MailboxName)
#Create the email message and set the Subject and Body
$message = New-Object Microsoft.Exchange.WebServices.Data.EmailMessage -ArgumentList $service
$message.Subject = $Subject
$message.Body = $Body
#If the -BodyAsHtml parameter is not used, send the message as plain text
if(!$BodyAsHtml) {
$message.Body.BodyType = 'Text'
}
if (Test-Path $Attachment) {
$message.Attachments.AddFileAttachment("$Attachment");
}
#Add each specified recipient
$To | ForEach-Object{
$null = $message.ToRecipients.Add($_)
}
#Add each specified carbon copy recipient
if($CcRecipients) {
$CcRecipients | ForEach-Object{
$null = $message.CcRecipients.Add($_)
}
}
#Add each specified blind copy recipient
if($BccRecipients) {
$BccRecipients | ForEach-Object{
$null = $message.BccRecipients.Add($_)
}
}
#Send the message and save a copy in the Sent Items folder
$message.SendAndSaveCopy()
} #End of Process Block
} #End of Function
#$credential = Get-Credential
$AttachmentPath = "C:\temp\myattachmentfile.csv"
$to = "sunnyc7@gmail.com"
$Subject = "Test email via Web Serices"
$Body = @"
This is the message Body.
You can include anything here alongwith notifications.
Adding more stuff here.
You can also use the body variable as parameter.
Time:: $(Get-date)
Sent from computer:: $env:computername
Sent by User:: $env:username
Thank You.
Sunny.
"@
$Splat = @{
To = $To
Subject = $Subject
Body =$Body
Credential = $cred2
Attachment = $AttachmentPath
}
Send-AAMEMailMessage @Splat
|
PowerShellCorpus/GithubGist/objectx_4131424_raw_06d5a50164054dc70b0b7b9aba7a8c44439c69a2_gistfile1.ps1
|
objectx_4131424_raw_06d5a50164054dc70b0b7b9aba7a8c44439c69a2_gistfile1.ps1
|
$mydir = Split-Path -parent $MyInvocation.MyCommand.Path
$work_dir = [Environment]::GetFolderPath("MyDocuments")
function start_process () {
$veracity = Join-Path $(Get-Item HKLM:\Software\Sourcegear\Veracity).GetValue("InstallPath") "vv.exe"
$processStartInfo = New-Object System.Diagnostics.ProcessStartInfo
$processStartInfo.FileName = $veracity
$processStartInfo.WorkingDirectory = $work_dir
$processStartInfo.UseShellExecute = $false
$processStartInfo.WindowStyle = "Normal"
$processStartInfo.Arguments = "serv"
#return $processStartInfo
$process = [System.Diagnostics.Process]::Start($processStartInfo)
if ($process) {
$global:veracity_pid = $process.Id
}
}
start_process
|
PowerShellCorpus/GithubGist/aetos382_2084bd09a926485eace6_raw_3ed3ddb5e2382e5a188437e874a55d24f884bf41_sample1.ps1
|
aetos382_2084bd09a926485eace6_raw_3ed3ddb5e2382e5a188437e874a55d24f884bf41_sample1.ps1
|
function Hoge
{
param(
[string[]] $x = @())
@($x) | % { ... }
}
|
PowerShellCorpus/GithubGist/janikvonrotz_5749524_raw_c427cb23627fc3b873eba31501a16b8908b13656_LoadModulesAndSnapins.ps1
|
janikvonrotz_5749524_raw_c427cb23627fc3b873eba31501a16b8908b13656_LoadModulesAndSnapins.ps1
|
# import all mdoules
Get-Module -ListAvailable | Import-Module
# show module commands
Get-Command –Module grouppolicy
#--------------------------------------------------#
# SharePoint
#--------------------------------------------------#
if(-not (Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue)){Add-PSSnapin "Microsoft.SharePoint.PowerShell"}
#--------------------------------------------------#
# SqlServer
#--------------------------------------------------#
if((Get-PSSnapin SqlServerCmdletSnapin100 -ErrorAction SilentlyContinue) -eq $Null){Add-PSSnapin SqlServerCmdletSnapin100}
if((Get-PSSnapin SqlServerProviderSnapin100 -ErrorAction SilentlyContinue) -eq $Null){Add-PSSnapin SqlServerProviderSnapin100}
#--------------------------------------------------#
# Quest ActiveDirectory
#--------------------------------------------------#
Import-Module Quest.ActiveRoles.ArsPowerShellSnapIn
#--------------------------------------------------#
# ActiveDirectory
#--------------------------------------------------#
Import-Module ActiveDirectory
#--------------------------------------------------#
# Windows Server Manager
#--------------------------------------------------#
Import-Module ServerManager
#--------------------------------------------------#
# Windows Server GroupPolicy
#--------------------------------------------------#
Import-Module GroupPolicy
#--------------------------------------------------#
# VMware vSphere PowerCLI
#--------------------------------------------------#
if((Get-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue) -eq $Null){Add-PSSnapin VMware.VimAutomation.Core}
if((Get-PSSnapin VMware.VimAutomation.Vds -ErrorAction SilentlyContinue) -eq $Null){Add-PSSnapin VMware.VimAutomation.Vds}
|
PowerShellCorpus/GithubGist/pepoluan_397ba99abe82480b1083_raw_de3dc13de73113e2761bfa2f47fc16c6df585949_CSV-FilterCols.ps1
|
pepoluan_397ba99abe82480b1083_raw_de3dc13de73113e2761bfa2f47fc16c6df585949_CSV-FilterCols.ps1
|
Function CSV-FilterCols() {
param (
[Parameter(Mandatory=$true)][String]$InCsv,
[Parameter(Mandatory=$true)][String[]]$ColNameRegex,
[Switch]$NoGlobal=$false,
[String]$CsvDelimiter=";",
[String]$OutCsv=""
)
If (!(Test-Path $InCsv)) {
Write-Error "File $InCsv not found!"
Return
}
$rawdata = Import-Csv $InCsv
# Store result of Import-Csv in a Global variable, just in case we want to do something with it, too
If (! $NoGlobal) { $Global:rawdata = $rawdata }
$colnames = $rawdata[0] | Get-Member -MemberType NoteProperty | ForEach { $_.Name }
$cols = New-Object -TypeName System.Collections.Generic.List[String]
$cols.Add($colnames[0])
foreach ($r in $ColNameRegex) {
# Need to cast return of @() to String[] so AddRange won't puke
$cols.AddRange([String[]]@($colnames -match $r))
}
$cols.Sort()
$cols = $cols.ToArray() | Get-Unique
$filtdata = $rawdata | select $cols
If ($OutCsv -eq "") {
$filtdata
}
Else {
$filtdata | Export-Csv $OutCsv -NoTypeInformation -Delimiter $CsvDelimiter
}
}
|
PowerShellCorpus/GithubGist/arjenvanderende_4496146_raw_456c9e1622356fd790f4ccc994479cbd2dfa441b_invert_mouse_wheel_direction.ps1
|
arjenvanderende_4496146_raw_456c9e1622356fd790f4ccc994479cbd2dfa441b_invert_mouse_wheel_direction.ps1
|
Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Enum\HID\*\*\Device` Parameters FlipFlopWheel -EA 0 | ForEach-Object { Set-ItemProperty $_.PSPath FlipFlopWheel 1 }
|
PowerShellCorpus/GithubGist/chgeuer_3905353_raw_3bce6b025e3bfaf8e74d9bb811bda8cc1f0dd412_setupLinuxInVPN.ps1
|
chgeuer_3905353_raw_3bce6b025e3bfaf8e74d9bb811bda8cc1f0dd412_setupLinuxInVPN.ps1
|
$vmname = "ptvlinux1"
$linuxUser = "ptvadmin"
$adminPassword = "!!test123"
$imagename = "ptv-itb-test1-linux-galleryimage"
$subnet = "azure2b"
$affinitygroup = "ptvtest"
$vnetname = "azure253"
$media = "https://portalvhdszxpyfbp32jw28.blob.core.windows.net/vhds/ptv-itb-1.vhd"
$cloudSvcName = "ptvlinux1"
#Get-AzureSubscription | select SubscriptionId, SubscriptionName
#Set-AzureSubscription -SubscriptionName PTV -SubscriptionId 30dcfc8a-56e5-4f20-a788-6e221e722b14 -CurrentStorageAccount portalvhdszxpyfbp32jw28
$vm = New-AzureVMConfig -Name $vmname -Label $vmname -InstanceSize Small -ImageName $imagename -MediaLocation $media | Add-AzureProvisioningConfig -Linux –LinuxUser $linuxUser -Password $adminPassword | Set-AzureSubnet -SubnetNames $subnet
New-AzureVM -ServiceName $cloudSvcName -VNetName $vnetname -VMs $vm -AffinityGroup $affinitygroup
|
PowerShellCorpus/GithubGist/ianblenke_27f29e3a4a64f0296abe_raw_428e4a8f043d67a1ecce764c1173856f7b1002be_Update-OneGet.ps1
|
ianblenke_27f29e3a4a64f0296abe_raw_428e4a8f043d67a1ecce764c1173856f7b1002be_Update-OneGet.ps1
|
<#
.NOTES
===========================================================================
Created with: PowerShell Studio 2014, Version 4.1.74
Created on: 11/10/2014 4:06 PM
Company: SAPIEN Technologies, Inc.
Contact: June Blender, juneb@sapien.com, @juneb_get_help
Filename: Update-OneGet.ps1
===========================================================================
.SYNOPSIS
Downloads, installs, and imports the latest OneGet module from GitHub.
.DESCRIPTION
Update-OneGet.ps1 downloads, installs, and (optionally) imports the
latest experimental version of the OneGet module from http://OneGet.org,
which is linked to the OneGet project in GitHub.
The script downloads the OneGet.zip file from OneGet.org and saves it in
your downloads folder, $home\Downloads. It unblocks the file, unzips it,
and installs it in the directory specified by the Path parameter.
If you include the optional Import parameter, the script imports the module
into the current session.
After running the script, to import the experimental version of OneGet into
any session, use the following command:
Import-Module <path>\OneGet.psd1
This script runs on Windows PowerShell 3.0 and later.
.PARAMETER Path
Specifies a directory where the script installs the module. This parameter is
required. Enter the path to a directory. Do not include a .zip file name extension.
If the directory does not exist, the script creates it. If the directory exists,
the script deletes the directory contents before installing the module. This lets
you reuse the directory when updating.
To prevent errors, specify a subdirectory of your Documents directory or a test
directory.
CAUTION: Do not specify a path in $pshome\Modules. Installing the experimental build
of OneGet in this directory might prevent you from installing, uninstalling,
or updating the official OneGet module from Microsoft.
.PARAMETER Import
Imports the module into the current session after installing it.
.EXAMPLE
.\Update-OneGet.ps1 -Path $home\Documents\Test\OneGet
This command installs the newest OneGet module in the $home\Documents\Test\OneGet
directory. To import it: Import-Module $home\Documents\Test\OneGet.psd1
.EXAMPLE
.\Update-OneGet.ps1 -Path $home\Documents\Test\OneGet -Import
This command installs the newest OneGet module in the
$home\Documents\Test\OneGet directory and imports it into the
current session.
.EXAMPLE
.\Update-OneGet.ps1 -Path $home\Documents\WindowsPowerShellModules\OneGet
This command installs the newest OneGet module in the your current-user
Modules directory. Windows PowerShell imports it automatically when you use a
command in the module, such as Find-Package.
.OUTPUTS
System.Management.Automation.PSCustomObject, System.Management.Automation.PSModuleInfo
If you use the Import parameter, Update-OneGet returns a module object. Otherwise, it
returns a custom object with the Path and LastWriteTime of the OneGet module manifest,
OneGet.psd1
#>
#Requires -Version 3
Param
(
[Parameter(Mandatory = $true)]
[ValidateScript({$_ -notlike "*.zip" -and $_ -notlike "$pshome*" -and $_ -notlike "*System32*"})]
[System.String]
$Path,
[Parameter(Mandatory=$false)]
[Switch]
$Import
)
#***************************#
# Helper Functions #
#***************************#
# Use this function on systems that do not have
# the Extract-Archive cmdlet (PS 5.0)
#
function Unzip-OneGetZip
{
$shell = New-Object -ComObject shell.application
$zip = $shell.NameSpace("$home\Downloads\OneGet.zip")
if (!(Test-Path $Path)) {$null = mkdir $Path}
foreach ($item in $zip.items())
{
$shell.Namespace($Path).Copyhere($item)
}
}
#***************************#
# Main #
#***************************#
# Remove current OneGet from session
if (Get-Module -Name OneGet) {Remove-Module OneGet}
# Create the $Path path
if (!(Test-Path $Path))
{
try
{
mkdir $Path | Out-Null
}
catch
{
throw "Did not find and cannot create the $Path directory."
}
}
else
{
dir $Path | Remove-Item -Recurse
}
#Download the Zip file to $home\Downloads
try
{
Invoke-WebRequest -Uri http://oneget.org/oneget.zip -OutFile $home\Downloads\OneGet.zip
}
catch
{
throw "Cannot download OneGet zip file from http://oneget.org"
}
if (!($zip = Get-Item -Path $home\Downloads\OneGet.zip))
{
throw "Cannot find OneGet zip file in $home\Downloads"
}
else
{
$zip | Unblock-File
if (Get-Command Expand-Archive -ErrorAction SilentlyContinue)
{
$zip | Expand-Archive -DestinationPath $Path
}
else
{
Unzip-OneGetZip
}
if (!(Test-Path $Path\OneGet.psd1))
{
throw "Cannot find OneGet.psd1 in $Path"
}
if ($Import)
{
Import-Module $Path\OneGet.psd1
if ((Get-Module OneGet).ModuleBase -ne $Path)
{
throw "Failed to import the new OneGet module from $Path."
}
else
{
Get-Module OneGet
}
}
else
{
[PSCustomObject]@{Path = "$Path\OneGet.psd1"; Date = (dir $Path\OneGet.psd1).LastWriteTime}
}
}
|
PowerShellCorpus/GithubGist/wadtech_4078495_raw_b2af7061604bc8ae310a892a28cb1ed451ff0a0c_Get-DistributionGroups.ps1
|
wadtech_4078495_raw_b2af7061604bc8ae310a892a28cb1ed451ff0a0c_Get-DistributionGroups.ps1
|
# List-DistributionGroups.ps1
# Peter Mellett 2012
#
# Find all distribution groups of a user and list them to the console
#
# Example:
# .\List-DistributionGroups.ps1 aperson@company.com
#
# Name
# ====
# Marketing
# Managers
#
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,Position=1)]
[string]$email
)
if (Test-Path 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1') {
. 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'
Connect-ExchangeServer -auto
Write-Host "$email belongs to: "
$lists = Get-DistributionGroup -ResultSize unlimited
$lists | where { (Get-DistributionGroupMember $_ | foreach {$_.PrimarySmtpAddress}) -contains $email } | select Name
} else {
Wite-Host "This script requires Exchange 2010 Shell to be installed. Either use this script on an Exchange server or install the EMC from the Exchange install media."
}
|
PowerShellCorpus/GithubGist/jeffpatton1971_aeee67af3ed8a713101c_raw_fe86ebd4430bcc3f5901edc92e036b7dbec095d2_Reset-HealthState.ps1
|
jeffpatton1971_aeee67af3ed8a713101c_raw_fe86ebd4430bcc3f5901edc92e036b7dbec095d2_Reset-HealthState.ps1
|
Function Reset-HealthState
{
param
(
$AlertName,
$ResolutionState
)
$Criteria = "Name like '$($AlertName)' and ResolutionState != $($ResolutionState)"
$Alerts = Get-SCOMAlert -Criteria $Criteria
ForEach($Alert in $Alerts)
{
$Monitor = Get-SCOMMonitor -Id $Alert.MonitoringRuleId
Get-SCOMClassInstance -id $Alert.MonitoringObjectId | foreach {$_.ResetMonitoringState($Monitor)}
}
}
Function Remove-ManagementGroup
{
#
# http://msdn.microsoft.com/en-us/library/hh329017.aspx
#
param ([string]$ManagementGroup)
$opsConfig = New-Object -ComObject AgentConfigManager.MgmtSvcCfg
$opsConfig.RemoveManagementGroup($ManagementGroup)
Restart-Service healthservice
}
|
PowerShellCorpus/GithubGist/kondratyev-nv_1d2de9ec85a93572ebc7_raw_13ab41fa2c7265c78aa7a405bc05b982ddfce795_rename.ps1
|
kondratyev-nv_1d2de9ec85a93572ebc7_raw_13ab41fa2c7265c78aa7a405bc05b982ddfce795_rename.ps1
|
# Set new name of project
$newname=$args[0]
# Rename .sln and .vcxproj files
Rename-Item .\project.vcxproj .\$newname.vcxproj
Rename-Item .\solution.sln .\$newname.sln
# Replace old project name to new in file .sln
$sln = gc .\$newname.sln
$sln | %{ $_ -creplace 'project', $newname }| Set-Content .\$newname.sln
# Replace old project name to new in file .vcxproj
$prj = gc .\$newname.vcxproj
$prj | %{ $_ -creplace 'project', $newname }| Set-Content .\$newname.vcxproj
|
PowerShellCorpus/GithubGist/pkirch_6b7f0f5e979ac9e35b57_raw_5838fe2b8f9d674a745a0d1a3ce36ea9614bdd69_StartingVMStatusSample.ps1
|
pkirch_6b7f0f5e979ac9e35b57_raw_5838fe2b8f9d674a745a0d1a3ce36ea9614bdd69_StartingVMStatusSample.ps1
|
Get-AzureVM
<# Output
ServiceName Name Status
----------- ---- ------
leasetest host1 ReadyRole
leasetest2 host2 ReadyRole
leasetest3 host3 RoleStateUnknown
leasetest4 host4 StoppedDeallocated
leasetest5 host5 StoppedDeallocated
#>
Get-AzureVM
<# Output
ServiceName Name Status
----------- ---- ------
leasetest host1 ReadyRole
leasetest2 host2 ReadyRole
leasetest3 host3 CreatingVM
leasetest4 host4 StoppedDeallocated
leasetest5 host5 StoppedDeallocated
#>
Get-AzureVM
<# Output
ServiceName Name Status
----------- ---- ------
leasetest host1 ReadyRole
leasetest2 host2 ReadyRole
leasetest3 host3 StartingVM
leasetest4 host4 StoppedDeallocated
leasetest5 host5 StoppedDeallocated
#>
|
PowerShellCorpus/GithubGist/peaeater_9650778_raw_0f2297760ced499db4bb76a67a3c87fecaf2aba4_meta2manifest.ps1
|
peaeater_9650778_raw_0f2297760ced499db4bb76a67a3c87fecaf2aba4_meta2manifest.ps1
|
# convert IA metadata XML to Solr-ready manifest XML
<#
metadata.imagecount - 2 => pagecount
metadata.identifier => WebSafe($1) => id
metadata.title => title, freetext
metadata.date => toDecade($1) => date, date_free, freetext
metadata.creator => name, name_free, freetext
metadata.publisher => name, name_free, freetext
metadata.year => date_free, freetext
metadata.volume => identifier_free, freetext
metadata.issue => identifier_free, freetext
metadata.month => identifier_free, freetext
metadata.call_number => identifier_free, freetext
metadata.editor => name, name_free, freetext
metadata.language => expand('eng'=) => language, freetext
#>
param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true,Position=0)]
[string]$in,
[Parameter(Position=1)]
[string]$out = ".\manifest.xml",
[Parameter(Position=2)]
[string]$source = "NO SOURCE PROVIDED"
)
process {
function WebSafe([string]$s) {
return $s.ToLowerInvariant().Replace(" ", "-")
}
# get an XMLTextWriter to create the manifest
$manifest = New-Object System.XMl.XmlTextWriter($out,$Null)
$manifest.Formatting = 'Indented'
$manifest.Indentation = 1
$manifest.IndentChar = "`t"
# write the header
$manifest.WriteStartDocument()
# create root elements
$manifest.WriteStartElement('add')
$manifest.WriteStartElement('doc')
# grab content from IA metadata
$metadata = New-Object -TypeName XML
$metadata.Load($in)
# page count total
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'pagecount')
$manifest.WriteCData(([int]$metadata.metadata.imagecount) - 2)
$manifest.WriteEndElement()
# base id
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'id')
$manifest.WriteCData((WebSafe($metadata.metadata.identifier)))
$manifest.WriteEndElement()
# identifier => srcid
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'srcid')
$manifest.WriteCData($metadata.metadata.identifier)
$manifest.WriteEndElement()
# title
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'title')
$manifest.WriteCData($metadata.metadata.title)
$manifest.WriteEndElement()
if ($metadata.metadata.date) {
# date => to be decaded (is that a word?) in DIH
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'date_ignored')
$manifest.WriteCData($metadata.metadata.date)
$manifest.WriteEndElement()
# free date
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'date_free')
$manifest.WriteCData($metadata.metadata.date)
$manifest.WriteEndElement()
# freetext date
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'freetext')
$manifest.WriteCData("<date label='Date'>" + $metadata.metadata.date + "</date>")
$manifest.WriteEndElement()
}
if ($metadata.metadata.creator) {
# creator => name
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'name')
$manifest.WriteCData($metadata.metadata.creator)
$manifest.WriteEndElement()
# creator => free name
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'name_free')
$manifest.WriteCData($metadata.metadata.creator)
$manifest.WriteEndElement()
# creator => freetext name
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'freetext')
$manifest.WriteCData("<name label='Creator'>" + $metadata.metadata.creator + "</name>")
$manifest.WriteEndElement()
}
if ($metadata.metadata.publisher) {
# publisher => name
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'name')
$manifest.WriteCData($metadata.metadata.publisher)
$manifest.WriteEndElement()
# publisher => free name
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'name_free')
$manifest.WriteCData($metadata.metadata.publisher)
$manifest.WriteEndElement()
# publisher => freetext name
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'freetext')
$manifest.WriteCData("<name label='Publisher'>" + $metadata.metadata.publisher + "</name>")
$manifest.WriteEndElement()
}
if ($metadata.metadata.editor) {
# editor => name
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'name')
$manifest.WriteCData($metadata.metadata.editor)
$manifest.WriteEndElement()
# editor => free name
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'name_free')
$manifest.WriteCData($metadata.metadata.editor)
$manifest.WriteEndElement()
# editor => freetext name
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'freetext')
$manifest.WriteCData("<name label='Editor'>" + $metadata.metadata.editor + "</name>")
$manifest.WriteEndElement()
}
if ($metadata.metadata.year) {
# year => date_free
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'date_free')
$manifest.WriteCData($metadata.metadata.year)
$manifest.WriteEndElement()
# year => freetext date
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'freetext')
$manifest.WriteCData("<date label='Year'>" + $metadata.metadata.year + "</date>")
$manifest.WriteEndElement()
}
if ($metadata.metadata.volume) {
# volume => identifier_free
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'identifier_free')
$manifest.WriteCData("Volume " + $metadata.metadata.volume)
$manifest.WriteEndElement()
# volume => freetext identifier
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'freetext')
$manifest.WriteCData("<identifier label='Volume'>" + $metadata.metadata.volume + "</identifier>")
$manifest.WriteEndElement()
}
if ($metadata.metadata.issue) {
# issue => identifier_free
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'identifier_free')
$manifest.WriteCData("Issue " + $metadata.metadata.issue)
$manifest.WriteEndElement()
# issue => freetext identifier
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'freetext')
$manifest.WriteCData("<identifier label='Issue'>" + $metadata.metadata.issue + "</identifier>")
$manifest.WriteEndElement()
}
if ($metadata.metadata.month) {
# month => identifier_free
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'identifier_free')
$manifest.WriteCData($metadata.metadata.month)
$manifest.WriteEndElement()
# month => freetext identifier
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'freetext')
$manifest.WriteCData("<identifier label='Month'>" + $metadata.metadata.month + "</identifier>")
$manifest.WriteEndElement()
}
if ($metadata.metadata.call_number) {
# call_number => identifier_free
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'identifier_free')
$manifest.WriteCData($metadata.metadata.call_number)
$manifest.WriteEndElement()
# call_number => freetext identifier
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'freetext')
$manifest.WriteCData("<identifier label='Call Number'>" + $metadata.metadata.call_number + "</identifier>")
$manifest.WriteEndElement()
}
if ($metadata.metadata.language) {
# language => language DIH (i.e. eng => English)
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'language_ignored')
$manifest.WriteCData($metadata.metadata.language)
$manifest.WriteEndElement()
# language => language_free
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'language_free')
$manifest.WriteCData($metadata.metadata.language)
$manifest.WriteEndElement()
# language => freetext language
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'freetext')
$manifest.WriteCData("<language label='Language'>" + $metadata.metadata.language + "</language>")
$manifest.WriteEndElement()
}
<# STATIC VALUES #>
# ocrtype 'djvu'
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'ocrtype')
$manifest.WriteCData("djvu")
$manifest.WriteEndElement()
# objectType 'textual record (electronic)'
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'objectType')
$manifest.WriteCData("textual record (electronic)")
$manifest.WriteEndElement()
# objectType freetext
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'freetext')
$manifest.WriteCData("<objectType label='Format'>textual record (electronic)</objectType>")
$manifest.WriteEndElement()
# onlineMediaRights 'No Restrictions'
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'onlineMediaRights')
$manifest.WriteCData("No Restrictions")
$manifest.WriteEndElement()
# onlineMediaType
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'onlineMediaType')
$manifest.WriteCData("Scanned Page")
$manifest.WriteEndElement()
# usageFlag
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'usageFlag')
$manifest.WriteCData("Internet Archive")
$manifest.WriteEndElement()
# source param => src because IA metadata does not include the name of the serial
$manifest.WriteStartElement('field')
$manifest.WriteAttributeString('name', 'src')
$manifest.WriteCData($source)
$manifest.WriteEndElement()
# close the doc/add nodes and finalize the document
$manifest.WriteEndElement()
$manifest.WriteEndElement()
$manifest.WriteEndDocument()
$manifest.Flush()
$manifest.Close()
# debug in notepad
#notepad $out
}
|
PowerShellCorpus/GithubGist/aokomoriuta_4995706_raw_a8caf927876b2946f6cd5e3e46220473f274b4e3_ReplaceFile.ps1
|
aokomoriuta_4995706_raw_a8caf927876b2946f6cd5e3e46220473f274b4e3_ReplaceFile.ps1
|
# カレントディレクトリに移動
cd "対象ディレクトリ";
# 各ファイルに対して操作
Get-ChildItem | ForEach-Object
{
# ファイル名を'-'で区切ってみたり
$data = $_.Name.Split('-');
# ファイル名が"H"で始まってたら除外したり
if($data[0][0] -ne 'H')
{
# 新しいファイル名を並び替えで作ったり
$newname = $data[1] + "-" + $data[0] + "-" + $data[2];
# pdfじゃなかったら末尾に"-abs.pdf"を追加したりして
if(!($newname.EndsWith(".pdf")))
{
$newname += "-abs.pdf";
}
# ファイル名を変更
Rename-Item $_ -newName $newname;
}
}
|
PowerShellCorpus/GithubGist/valenz_3f11468da5f426342336_raw_11112fb6723473ffaa11085e4fea8a9614f8b1c7_install.ps1
|
valenz_3f11468da5f426342336_raw_11112fb6723473ffaa11085e4fea8a9614f8b1c7_install.ps1
|
# EXCEPTION:
# Die Datei "I:\Downloads\install.ps1" kann nicht geladen werden, da die Ausführung von Skripts auf diesem System
# deaktiviert ist. Weitere Informationen finden Sie unter "about_Execution_Policies"
# (http://go.microsoft.com/fwlink/?LinkID=135170).
# + CategoryInfo : Sicherheitsfehler: (:) [], ParentContainsErrorRecordException
# + FullyQualifiedErrorId : UnauthorizedAccess
#
# TYPE:
# Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -ErrorAction Stop -Force -Verbose
# Define Chocolatey packages
$pkgList = @(
"git.commandline",
"7zip.commandline",
# "git.install",
# "7zip.install",
"virtualclonedrive",
"clover",
"google-chrome-x64",
"firefox",
"vlc",
"skype",
"dotnet4.5.2",
"powershell4"
);
# Check installation of Chocolatey
Write-Output 'Check installation of Chocolatey ...';
$getChoco = choco version | Select-String -Pattern 'name' | Select-Object Line;
if(-NOT $getChoco.Line) {
# Check installation of .NET Framework
Write-Output 'Check installation of .NET Framework ...';
$getDotNet = gci 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' | sort pschildname -des | select -fi 1 -exp pschildname;
if(-Not $getDotNet) {
Write-Warning -Message 'You need to install .NET Framework first, before you can use Chocolatey.';
Return;
} else {
Write-Host 'The most recently installed version of .NET Framework is'$getDotNet -ForegroundColor DarkCyan -BackgroundColor Black;
Write-Warning -Message 'Chocolatey not found on your system';
Write-Output 'Installing ...';
# For this .NET Framework must be installed already
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'));
}
} else {
# Get installation path
$getPath = Get-Command choco -ErrorAction SilentlyContinue | Select-Object Path;
Write-Host 'Found in'$getPath.Path -ForegroundColor DarkCyan -BackgroundColor Black;
}
# Check set of system variable
$getEnv = Get-ChildItem env:\ChocolateyInstall;
if(-Not $getEnv.Name) {
Write-Warning -Message 'Chocolatey system variable not found in the evironment variables';
Write-Output 'Setting up ...';
$env:ChocolateyInstall='C:\ProgramData\chocolatey';
}
# Update packages
Write-Output 'Search for package updates ...';
choco update;
# Install package list
if($pkgList) {
Write-Output 'Try to install packages ...';
foreach($item in $pkgList) {
choco install $item;
}
} else {
Write-Output 'Nothing to install.';
}
# Show installed packages
Write-Output '' 'Show installed packages:' '------------------------';
choco list -lo;
Write-Output '' 'Type "choco help" for further informations.';
# Restart computer confirmation
if($pkgList) {
Write-Output '';
Write-Warning 'The computer must be restarted. Do you want to do this now?';
Restart-Computer -Confirm;
}
|
PowerShellCorpus/GithubGist/russellds_9688526_raw_9a7cf684053a6f16c799fc7ed4d3ade3162985b1_ConvertFrom-Html.ps1
|
russellds_9688526_raw_9a7cf684053a6f16c799fc7ed4d3ade3162985b1_ConvertFrom-Html.ps1
|
function ConvertFrom-Html {
#.Synopsis
# Convert a table from an HTML document to a PSObject
#.Example
# Get-ChildItem | Where { !$_.PSIsContainer } | ConvertTo-Html | ConvertFrom-Html -TypeName Deserialized.System.IO.FileInfo
# Demonstrates round-triping files through HTML
param(
# The HTML content
[Parameter(ValueFromPipeline=$true)]
[string]$Html,
# A TypeName to inject to PSTypeNames
[string]$TypeName
)
begin { $content = "$html" }
process { $content += "$html" }
end {
[xml]$table = $content -replace '(?s).*<table[^>]*>(.*)</table>.*','<table>$1</table>'
$header = $table.table.tr[0]
$data = $table.table.tr[1..$table.table.tr.Count]
foreach($row in $data){
$item = @{}
$h = "th"
if(!$header.th) {
$h = "td"
}
for($i=0; $i -lt $header.($h).Count; $i++){
if($header.($h)[$i] -is [string]) {
$item.($header.($h)[$i]) = $row.td[$i]
} else {
$item.($header.($h)[$i].InnerText) = $row.td[$i]
}
}
Write-Verbose ($item | Out-String)
$object = New-Object PSCustomObject -Property $item
if($TypeName) {
$Object.PSTypeNames.Insert(0,$TypeName)
}
Write-Output $Object
}
}
}
|
PowerShellCorpus/GithubGist/hsiboy_c09e8598000893dbdd96_raw_affce98486f02a3d17c844a3226707a4a7b34254_chocolateyNewRelicInstall.ps1
|
hsiboy_c09e8598000893dbdd96_raw_affce98486f02a3d17c844a3226707a4a7b34254_chocolateyNewRelicInstall.ps1
|
$packageName = 'NewRelic.NetAgent'
$fileType = 'msi'
$license = '0000000000';
$proxy = 'http://proxy.big-corp.com:8080';
$host = gc env:computername
$silentArgs = "/norestart /q NR_LICENSE_KEY=" + $license + " NR_HOST=" + $host + " NR_PROXY_ADDRESS=" + $proxy + ' /l*v c:\log.log';
$url = 'https://download.newrelic.com/dot_net_agent/release/NewRelicAgent_x86_3.10.43.0.msi'
$url64bit = 'https://download.newrelic.com/dot_net_agent/release/NewRelicAgent_x64_3.10.43.0.msi'
Install-ChocolateyPackage $packageName $fileType $silentArgs $url $url64bit
|
PowerShellCorpus/GithubGist/mkchandler_8864804_raw_e9806a99d0ea23470ce0ca59988b5a707cbefcd5_DisableNuGetPackageRestore.ps1
|
mkchandler_8864804_raw_e9806a99d0ea23470ce0ca59988b5a707cbefcd5_DisableNuGetPackageRestore.ps1
|
# Usage: .\DisableNuGetPackageRestore.ps1 C:\Path\To\Solution.sln
# Get the path that the user specified when calling the script
$solution = $args[0]
$solutionPath = Split-Path $solution -Parent
$solutionName = Split-Path $solution -Leaf
# Delete the .nuget directory and all contents
Remove-Item (Join-Path $solutionPath ".nuget") -Force -Recurse -ErrorAction 0
# Create a backup of the solution file
Copy-Item $solution $("$solution.bak")
# Clear out the solution file
Clear-Content $solution
# Flag field used to denote what part of the solution file we are in
# 0: Not inside section
# 1: Beginning and middle of section
# 2: Last line of the section
$foundNuGetSection = 0
# Create the new contents of the solution file without the NuGet section
(Get-Content $("$solution.bak")) |
Foreach-Object {
# Parsing the solution file layout is no fun...
if ($_ -match "^Project.*nuget.*") {
$foundNuGetSection = 1
} elseif ($_ -match "^EndProject$" -and $foundNuGetSection -eq 1) {
$foundNuGetSection = 2
} elseif ($foundNuGetSection -eq 2) {
$foundNuGetSection = 0
}
if ($foundNuGetSection -eq 0) {
Add-Content -Encoding UTF8 $solution $_
}
}
# Remove the temporary solution backup file
Remove-Item $("$solution.bak")
# Find every .csproj file and remove the reference to the NuGet.targets file
# Example: <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
Get-ChildItem $solutionPath *.csproj -recurse |
Foreach-Object {
(Get-Content $_.PSPath) | Where-Object {$_ -notmatch 'NuGet.targets'} | Set-Content -Encoding UTF8 $_.PSPath
}
|
PowerShellCorpus/GithubGist/xpando_8a896d903ceb7cc31192_raw_34d99877fbbde7c36bd6b7d27caad3ce607e2928_unzip.ps1
|
xpando_8a896d903ceb7cc31192_raw_34d99877fbbde7c36bd6b7d27caad3ce607e2928_unzip.ps1
|
function unzip($path,$to) {
$7z = "$env:TEMP\7z"
if (!(test-path $7z) -or !(test-path "$7z\7za.exe")) {
if (!(test-path $7z)) { md $7z | out-null }
push-location $7z
try {
write-host "Downloading 7zip" -foregroundcolor cyan
$wc = new-object system.net.webClient
$wc.headers.add('user-agent', [Microsoft.PowerShell.Commands.PSUserAgent]::FireFox)
$wc.downloadFile("http://softlayer-dal.dl.sourceforge.net/project/sevenzip/7-Zip/9.20/7za920.zip","$7z\7z.zip")
write-host "done." foregroundcolor green
add-type -assembly "system.io.compression.filesystem"
[io.compression.zipfile]::extracttodirectory("$7z\7z.zip","$7z")
del .\7z.zip
}
finally { pop-location }
}
if ($path.endswith('.tar.gz') -or $path.endswith('.tgz')) {
# This is some crazy s**t right here
$x = "cmd"
$y = "/C `"^`"$7z\7za.exe^`" x ^`"$path^`" -so | ^`"$7z\7za.exe^`" x -y -si -ttar -o^`"$to^`""
& $x $y
} else {
& "$7z\7za.exe" x $path -y -o"$to"
}
}
|
PowerShellCorpus/GithubGist/ebouwsema_e090c38534fa5515c3e9_raw_b5b42324547d09f3a9622114d8712f291319723a_CopyRemoteDatabase.ps1
|
ebouwsema_e090c38534fa5515c3e9_raw_b5b42324547d09f3a9622114d8712f291319723a_CopyRemoteDatabase.ps1
|
## Based on code by: Gianluca Sartori - @spaghettidba
#
# Loads the SQL Server Management Objects (SMO)
#
#Add-PSSnapin SqlServerCmdletSnapin100
#Add-PSSnapin SqlServerProviderSnapin100
Import-Module sqlps -DisableNameChecking
function Get-DefaultFileDirectories
(
[string]$server=$(throw "Server instance required.")
)
{
$sql = "SELECT [ROWS] as DataDir, [LOG] as LogDir
FROM (
SELECT type_desc,
SUBSTRING(physical_name,1,LEN(physical_name) - CHARINDEX('\', REVERSE(physical_name)) + 1) AS physical_name
FROM master.sys.database_files
) AS src
PIVOT( MIN(physical_name) FOR type_desc IN ([ROWS],[LOG])) AS pvt"
return Invoke-sqlcmd -Query $sql -ServerInstance $server
}
function Get-BackupDirectory
(
[string]$server=$(throw "Server instance required.")
)
{
$sql = "EXEC master.dbo.xp_instance_regread
N'HKEY_LOCAL_MACHINE',
N'Software\Microsoft\MSSQLServer\MSSQLServer',
N'BackupDirectory'"
$result = Invoke-sqlcmd -Query $sql -ServerInstance $server
return $result.Data
}
function Get-LogicalFileNames
(
[string]$server=$(throw "Server instance required."),
[string]$database=$(throw "Database name required.")
)
{
$sql = "SELECT [1] AS DataFile, [2] AS LogFile
FROM (
SELECT
f.name AS [FileName], f.fileid AS FileID
FROM
sys.sysdatabases d
INNER JOIN sys.sysaltfiles f ON d.dbid = f.dbid
WHERE d.name = '$database'
) AS src
PIVOT( MIN([FileName]) FOR FileID IN ([1],[2])) AS pvt"
return Invoke-sqlcmd -Query $sql -ServerInstance $server
}
function Invoke-BackupDatabase
(
[string]$server=$(throw "Server instance required."),
[string]$database=$(throw "Database name required."),
[string]$backupDir=$(throw "Backup destination directory required.")
)
{
$ts = Get-Date -Format yyyyMMdd
$backupFile = $database + "_" + $ts + ".bak"
$backupPath = $backupDir + "\" + $backupFile
$sql = "BACKUP DATABASE $database TO DISK='$BackupPath' WITH INIT, COPY_ONLY, COMPRESSION, FORMAT;"
Invoke-Sqlcmd -Query $sql -ServerInstance $server -QueryTimeout 65535
return [string]$backupPath
}
function Invoke-RestoreDatabase
(
[string]$server=$(throw "Server instance required."),
[string]$database=$(throw "Database name required."),
[string]$backupPath=$(throw "Backup source path required."),
[bool]$singleUser=$false
)
{
#
# Read master database files location
#
$dirs = Get-DefaultFileDirectories $server
$dataDir = $dirs.DataDir
$logDir = $dirs.LogDir
$sqlSingleUser = "
ALTER DATABASE $database SET SINGLE_USER WITH ROLLBACK AFTER 10 SECONDS"
$sqlRestore = "
RESTORE DATABASE $database
FROM DISK='$backupPath'
WITH RECOVERY, REPLACE"
$sqlFileList = "
RESTORE FILELISTONLY
FROM DISK='$backupPath'"
$i = 0
Invoke-Sqlcmd -Query $sqlFileList -ServerInstance $server -QueryTimeout 65535 | ForEach-Object {
$currentRow = $_
$physicalName = [System.IO.Path]::GetFileName($currentRow.PhysicalName)
if($currentRow.Type -eq "D") {
$newName = $dataDir + $database + ".MDF"
} else {
$newName = $logDir + $database + ".LDF"
}
$sqlRestore += ","
$sqlRestore += "
MOVE '$($CurrentRow.LogicalName)' TO '$NewName'"
$i += 1
}
try {
Write-Host " Invoking Restore Command: $($sqlRestore.Trim('`n').Replace('`n','`n`t`t`t'))"
Invoke-Sqlcmd -Query $sqlRestore -ServerInstance $server -QueryTimeout 65535
} catch [Exception] {
if (!($singleUser)) {
if ($_.Exception.Message.StartsWith("Exclusive access could not be obtained because the database is in use.")) {
Write-Host " Database in use. Forcing Single User Mode and retrying restore."
Invoke-Sqlcmd -Query $sqlSingleUser -ServerInstance $server -QueryTimeout 65535
Invoke-RestoreDatabase $server $database $backupPath $true
return
}
}
throw
}
}
function Invoke-CopyDatabase
(
[string]$srcDb=$(throw "Source Database (srcDb) required."),
[string]$srcServer=$(throw "Source Server (srcServer) required."),
[string]$srcServerUNC=$(throw "Source Server UNC (srcServerUNC) required."),
[string]$dstDb=$(throw "Destination Database (dstDb) required."),
[string]$dstServer=$(throw "Destination Server (dstServer) required."),
[string]$dstShare=$(throw "Destination Network Share (dstShare) required."),
[string]$dstDir=$(throw "Destination Logical Directory (dstDir) required."),
[string]$srcShare=$null,
[string]$srcDir=$null
)
{
Write-Host "Copying Database '$srcDb' from '$srcServer' to '$dstDb' on '$dstServer'."
Write-Host "---"
#
# Read default backup path of the source from the registry
#
if (!($srcDir)) {
$backupDir = Get-BackupDirectory $srcServer
} else {
$backupDir = $srcDir
}
#
# Process all user databases
#
$sqlSourceDatabase = "
SELECT name
FROM master.sys.databases
WHERE name LIKE '$srcDb'
"
$info = Invoke-sqlcmd -Query $sqlSourceDatabase -ServerInstance $srcServer
if ($info -eq $null) {
write-host "Source database '$srcDb' not found."
return
}
$info | ForEach-Object {
try {
$dbName = $_.Name
#
# Backup remote database
#
Write-Host "1 - Backing up SOURCE database '$dbName' on '$srcServer'"
$srcBackupPath = Invoke-BackupDatabase $srcServer $dbName $backupDir
Write-Host " Database backed up to '$srcBackupPath'"
#
# Move the backup to the destination
#
$backupFile = [System.IO.Path]::GetFileName($srcBackupPath)
$dstBackupPath = ($dstDir + "\" + $backupFile).Replace('\\', '\')
if (!($srcShare)) {
$srcBackupURN = $srcBackupPath.Substring(1, 2)
$srcBackupURN = $srcBackupPath.Replace($srcBackupURN, $srcBackupURN.replace(":","$"))
$srcBackupURN = "\\" + $srcServerUNC + "\" + $srcBackupURN
} else {
$srcBackupURN = $srcShare + "\" + $backupFile
}
Write-Host "2 - Copying backup file '$srcBackupURN' to '$dstShare'"
Copy-Item $srcBackupURN $dstShare -Force
try {
Write-Host "3 - Backing up DESTINATION database '$dstDb' on '$dstServer'"
$backupPath = Invoke-BackupDatabase $dstServer $dstDb $dstDir
Write-Host " Database backed up to '$backupPath'"
} catch [Exception] {
if($_.Exception.Message.StartsWith("Database '$dstDb' does not exist.")) {
Write-Host " Destination database does not exist - no backup made."
} else {
throw
}
}
Invoke-RestoreDatabase $dstServer $dstDb $dstBackupPath
Write-Host "4 - Restored '$dstDb' on '$dstServer'"
#
# Delete the backup file
#
Write-Host "5 - Deleting SOURCE backup file '$dstBackupPath'"
Remove-Item $dstBackupPath -ErrorAction SilentlyContinue
}
catch {
Write-Error $_
}
}
Write-Host "---"
Write-Host "Finished!"
}
cls
sl "c:\"
$ErrorActionPreference = "Stop"
# Input your parameters here
$srcDb = "RFOCentral_Demo"
$srcServer = "PROD-SQL01\RFO"
$srcServerUNC = "PROD-SQL01"
$dstServer = "DYNA-DEVWEB01"
$dstDb = "RFOCentral_Encana_DEV"
$dstShare = "\\DYNA-DEVWEB01\Backups"
$dstDir = "C:\Backups"
$srcShare = "\\PROD-SQL01\Backups"
$srcDir = "C:\Backups"
Invoke-CopyDatabase $srcDb $srcServer $srcServerUNC $dstDb $dstServer $dstShare $dstDir $srcShare $srcDir
|
PowerShellCorpus/GithubGist/ianblenke_88a44731e83fa57abe3c_raw_dcec6de76ee447d2d58b59adc0477394ac55d71a_InstallUse_OneGet.ps1
|
ianblenke_88a44731e83fa57abe3c_raw_dcec6de76ee447d2d58b59adc0477394ac55d71a_InstallUse_OneGet.ps1
|
# Install Microsoft's OneGet and start using it
icm $executioncontext.InvokeCommand.NewScriptBlock((New-Object Net.WebClient).DownloadString('https://gist.githubusercontent.com/ianblenke/27f29e3a4a64f0296abe/raw/428e4a8f043d67a1ecce764c1173856f7b1002be/Update-OneGet.ps1')) -ArgumentList $home\Documents\WindowsPowerShellModules\OneGet
Import-Module $home\Documents\WindowsPowerShellModules\OneGet\OneGet.psd1
|
PowerShellCorpus/GithubGist/VertigoRay_6524236_raw_9d570bf2ac4e2b5dfbd77ecea44b34f455c94f2e_sig.ps1
|
VertigoRay_6524236_raw_9d570bf2ac4e2b5dfbd77ecea44b34f455c94f2e_sig.ps1
|
[string](0..9|%{[char][int](32+("54698284737179506589").substring(($_*2),2))})-replace "\s{1}\b"
|
PowerShellCorpus/GithubGist/yuuichirou_8227275_raw_54ca7eeb54970c4dcf06a0dddccc567942343697_start_on_remote.ps1
|
yuuichirou_8227275_raw_54ca7eeb54970c4dcf06a0dddccc567942343697_start_on_remote.ps1
|
Clear-Host
$proc = Get-WmiObject Win32_Process -Filter "name='javaw.exe'" | select-Object CommandLine,Name,ProcessId,Status,ThreadCount
Write-Host $proc
#Stop-Process $proc.ProcessId
|
PowerShellCorpus/GithubGist/RitchieFlick_9621461_raw_9606b64559a32c5262c50914a29b83970f8a6a50_Powershell_Prompt.ps1
|
RitchieFlick_9621461_raw_9606b64559a32c5262c50914a29b83970f8a6a50_Powershell_Prompt.ps1
|
<#
.SYNOPSIS
Personal Powershell profile of ritchief
.DESCRIPTION
This is the Powershell script for ritchief's personal Powershell
Prompt. This includes many ideas, tips and tricks from different places
and blogs. Links are added in the .LINK section.
.LINK
https://gist.github.com/RitchieFlick/9621461
http://winterdom.com/2008/08/mypowershellprompt
#>
<# ============================================================================
Functions which are executed before the command prompt is set
=========================================================================#>
# Script Parameters
$start_folder = "F:\data"
<#
.SYNOPSIS
Sets the start folder
.DESCRIPTION
Depending if the desired start_folder exists, the start location
of the shell is pointed to that folder, if not, the $HOME folder
is used.
#>
function Set_StartFolder {
if (Test-Path $start_folder) { Set-Location $start_folder }
else { Set-Location $HOME }
}
<#
.SYNOPSIS
Sets some standard settings for the powershell console
.DESCRIPTION
This function sets the background color and the window title
for the powershell console.
#>
function Set_Console_Settings {
$host_rawUI = (Get-Host).UI.RawUI
$host_rawUI.WindowTitle = "$env:USERNAME @ $env:COMPUTERNAME"
}
# Execute pre-prompt configuration functions
Set_StartFolder
Set_Console_Settings
<# ============================================================================
Prompt function and its *helper* functions
=========================================================================#>
<#
.SYNOPSIS
Builds the custom prompt
.DESCRIPTION
This is a function, specified by powershell itself to define
and customize the command prompt.
#>
function prompt {
Write-Host
Write-Host ("-> ") -nonewline
Print-User-Computer-Name
Print-Battery-Remaining-Percentage
Write-Host (" ")
Write-Host (" ") -nonewline
Print-Full-Date-Time
Write-Host
Write-Host ("-> ") -nonewline
Write-Host (shorten-path (pwd).Path) -foregroundcolor Green -nonewline
Write-Host (" :: ") -ForegroundColor Cyan -NoNewline
Write-Host ([char]8747 + [char]955 + ":") -foregroundcolor Magenta -nonewline
Test-If-Admin-Rights
return " "
}
<#
.SYNOPSIS
Formated output for the user- and computername.
.DESCRIPTION
Function which writes a formated output containing
the user- and computername for fast usage.
#>
function Print-User-Computer-Name {
Write-Host ($env:USERNAME) -foregroundcolor Yellow -nonewline
Write-Host (" @ ") -foregroundcolor DarkRed -nonewline
Write-Host ($env:COMPUTERNAME) -foregroundcolor DarkGreen -nonewline
}
<#
.SYNOPSIS
Function which returns the remaining battery percentage
.DESCRIPTION
This function returns (when applicable) the current/remaing battery
percentage and depending on how much energy is left, it changes the
color of its output.
#>
function Print-Battery-Remaining-Percentage {
$charge = get-wmiobject Win32_Battery
if ($charge -ne $null) {
if ($charge.EstimatedChargeRemaining -lt 50) {
Write-Host "=> Battery remaining:" $charge.EstimatedChargeRemaining -nonewline -backgroundcolor Yellow
}
elseif ($charge.EstimatedChargeRemaining -lt 20) {
Write-Host "=> Battery remaining:" $charge.EstimatedChargeRemaining -nonewline -backgroundcolor Red
}
else {
Write-Host "=> Battery remaining:" $charge.EstimatedChargeRemaining -nonewline
}
}
}
<#
.SYNOPSIS
Prints the full date and time
.DESCRIPTION
Small function which writes a formated string containing
the full date and time information to the host.
#>
function Print-Full-Date-Time {
$date_time = Get-Date -Format F
Write-Host $date_time -NoNewline -foregroundcolor DarkCyan
}
<#
.SYNOPSIS
Function which writes out if you're running admin rights or not
.DESCRIPTION
Function which writes to the console if you're running with admin
rights or not as a reminder.
#>
function Test-If-Admin-Rights {
if (([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
[Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Host " <admin> " -foregroundcolor Red -nonewline
}
}
# This is shamelessy stolen from Tomas Restrepo
# http://winterdom.com/2008/08/mypowershellprompt
function shorten-path([string] $path) {
$loc = $path.Replace($HOME, '~')
# remove prefix for UNC paths
$loc = $loc -replace '^[^:]+::', ''
# make path shorter like tabs in Vim,
# handle paths starting with \\ and . correctly
return ($loc -replace '\\(\.?)([^\\])[^\\]*(?=\\)','\$1$2')
}
|
PowerShellCorpus/GithubGist/mwinkle_5530485_raw_23101d6f6e1f1f1c8da570e4aac0bfb3602b2d84_get-gitrepos.ps1
|
mwinkle_5530485_raw_23101d6f6e1f1f1c8da570e4aac0bfb3602b2d84_get-gitrepos.ps1
|
# start of something to help me manage git repos...
# starting with a very basic list of them.
gci -recurse -force -include .git | select -Property Parent, {$_.Parent.FullName}
# ideal next step would potentially parse & return a list of remotes...
# once I get remotes, I should also output current branches
# serialize to a json doc and allow me to pick that back up elsewhere
# integrate iwth a convention to turn into a true one-liner to sync a box
|
PowerShellCorpus/GithubGist/hotpicklesoup_b922fe6efb5cab08f66f_raw_6a56a1c41fe42a15b5f26003e5c0dd299a49d7dd_UpdateDestination.ps1
|
hotpicklesoup_b922fe6efb5cab08f66f_raw_6a56a1c41fe42a15b5f26003e5c0dd299a49d7dd_UpdateDestination.ps1
|
function UpdateDestination {
Param(
$PUT_uri,
$Update_objs
)
$i = 0
ForEach ($obj in $Update_objs){
$i++
Write-Progress -id 0 -Activity "Updating $([string]$Obj.ObjectTypeName)" -Status $obj.name -PercentComplete (($i / $Update_objs.count) * 100)
Try {
$response = Invoke-WebRequest -Uri $PUT_uri$([string]$obj.objectid) -Headers $headers -TimeoutSec 120 -Method PUT -Body $obj.outerxml -OutVariable response
Add-content $log -value "$(get-date -format u) $($response.StatusCode) $($response.statusdescription) Updating $([string]$obj.name) with PUT on $PUT_uri$([string]$obj.objectid)"
}
Catch {
$error[0].exception
"PUT $PUT_uri$([string]$obj.objectid)"
$obj.outerxml
Add-content $log -value "$(get-date -format u) ERROR:$error[0].exception Updating $([string]$obj.name) with PUT on $PUT_uri$([string]$obj.objectid)"
}
}
}
|
PowerShellCorpus/GithubGist/jasonsedwards_1876643_raw_fc8d514c90ff5d97bb2ce7ca8af383b6525cefb1_getouad.ps1
|
jasonsedwards_1876643_raw_fc8d514c90ff5d97bb2ce7ca8af383b6525cefb1_getouad.ps1
|
# Function Find users OU
function getADGroup { param([string]$adfindtype, [string]$cName)
# Create A New ADSI Call
$root = [ADSI]''
# Create a New DirectorySearcher Object
$searcher = new-object System.DirectoryServices.DirectorySearcher($root)
# Set the filter to search for a specific CNAME
$searcher.filter = "(&(objectClass=$adfindtype) (sAMAccountName=$cName))"
# Set results in $adfind variable
$adfind = $searcher.findall()
# If Search has Multiple Answers
if ($adfind.count -gt 1) {
$count = 0
foreach($i in $adfind)
{
# Write Answers On Screen
write-host $count ": " $i.path
$count += 1
}
# Prompt User For Selection
$selection = Read-Host "Please select item: "
# Return answer using a combintaion of substring, indexOf & slice methods
$s = $adfind[$selection].path
$s = $s.substring($s.indexOf("OU=")+3).split(",")
return $s[0]
}
# Return answer using a combintaion of substring, indexOf & slice methods
$s = $adfind[0].path
$s = $s.substring($s.indexOf("OU=")+3).split(",")
return $s[0]
}
|
PowerShellCorpus/GithubGist/underwhelmed_389767_raw_b91ba07bf796aa3034af0f5e3d2eefa61ac83578_sp_compilation_validation.ps1
|
underwhelmed_389767_raw_b91ba07bf796aa3034af0f5e3d2eefa61ac83578_sp_compilation_validation.ps1
|
$server = "localhost"; # The SQL Server instance name
$database = "MyDB"; # The database name
# Load the SMO assembly
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | out-null
# Create the SMO objects
$srv = New-Object "Microsoft.SqlServer.Management.SMO.Server" $server;
$db = New-Object ("Microsoft.SqlServer.Management.SMO.Database");
# Get the database
$db = $srv.Databases[$database];
# For each stored procedure in the database
foreach($proc in $db.StoredProcedures)
{
# NOTE: my stored procedures are all prefixed with "web_"
if ($proc.Name.StartsWith("web_"))
{
$proc.TextBody = $proc.TextBody;
$proc.Alter();
Write-Host "Altered " $proc.Name;
}
}
|
PowerShellCorpus/GithubGist/codingoutloud_6782961_raw_2aee061f8ca07e78ca795092cad2ebff8e157223_which.ps1
|
codingoutloud_6782961_raw_2aee061f8ca07e78ca795092cad2ebff8e157223_which.ps1
|
<#
Implements the Unix shell 'which' command using PowerShell.
original: https://gist.github.com/codingoutloud/6782961
#>
function WhichOnes
{
if ($args.Count -eq 0)
{
# obviously use of 'which' in usage text is a hack (since it is chosen to match the alias)
Write-Host "usage: which [cmd1] [cmd2] ..."
}
else
{
Get-Command $args -All -ErrorAction SilentlyContinue | Format-Table Definition
}
}
New-Alias which WhichOnes
|
PowerShellCorpus/GithubGist/pohatu_10627192_raw_5df6e680589c5a53005d14969dee940ef00008da_fizzbuzz.ps1
|
pohatu_10627192_raw_5df6e680589c5a53005d14969dee940ef00008da_fizzbuzz.ps1
|
1..100|%{"fizz"*!($_%3)+"buzz"*!($_%5)+"$_"*!(!($_%3)-or!($_%5));}
|
PowerShellCorpus/GithubGist/morgansimonsen_8529297_raw_79582104508e42ef91b7cf3471804d05ed579626_Control-AzureVMs.ps1
|
morgansimonsen_8529297_raw_79582104508e42ef91b7cf3471804d05ed579626_Control-AzureVMs.ps1
|
# Control-AzureVMs.ps1
# Shut down or start a set of Windows Azure VMs in sequence
# v0.1 2014-01-20
#
# Morgan Simonsen
# www.cloudpower.no
# morgansimonsen.wordpress.com
Select-AzureSubscription "<subscription name>"
If ($args[1] -eq $null)
{ $VMs = Get-Content (Join-Path $PSScriptRoot "Control-AzureVMs.txt")}
Else
{ $VMs = Get-Content $args[1] }
Switch ($args[0])
{
Stop
{
[array]::Reverse($VMs) # Must shut down in reverse order
$VMs | ForEach `
{
$VM = $_ -split ";"
Write-Host "Stopping VM:"$VM[1]
Stop-AzureVM -ServiceName $VM[0] -Name $VM[1] -Force
}
}
Start
{
$VMs | ForEach `
{
$VM = $_ -split ";"
Write-Host "Starting VM:"$VM[1]
Start-AzureVM -ServiceName $VM[0] -Name $VM[1]
$VMStatus = Get-AzureVM -ServiceName $VM[0] -Name $VM[1]
While ($VMStatus.InstanceStatus -ne "ReadyRole")
{
write-host " Waiting...Current Status = " $VMStatus.Status
Start-Sleep -Seconds 15
$VMStatus = Get-AzureVM -ServiceName $VM[0] -name $VM[1]
}
}
}
}
|
PowerShellCorpus/GithubGist/JeremySkinner_383624_raw_fdb3357512cb9d13570a7de1c5d6474d48279d87_SwitchAutoCrlfSettingsToFalse.ps1
|
JeremySkinner_383624_raw_fdb3357512cb9d13570a7de1c5d6474d48279d87_SwitchAutoCrlfSettingsToFalse.ps1
|
# Takes a repository which has autocrlf set to true and changes it to false using powershell
# Turn autocrlf off
git config core.autocrlf false
# Remove all files
git rm --cached -r .
# Re-add all files
git diff --cached --name-only | foreach { git add $_ }
|
PowerShellCorpus/GithubGist/sunnyc7_04a285bafd56d89d4bac_raw_1ea38f5e5e711bff1d16cc202abd6b0bdf80c4de_Sharestate.ps1
|
sunnyc7_04a285bafd56d89d4bac_raw_1ea38f5e5e711bff1d16cc202abd6b0bdf80c4de_Sharestate.ps1
|
# Sharing state across different runspaces using a shared variable
# Expirmenting with Boe's stuff
# http://learn-powershell.net/2013/04/19/sharing-variables-and-live-objects-between-powershell-runspaces/
# Create a synhronized HashTable which will be shared across different runspaces
$hash = [hashtable]::Synchronized(@{})
$hash.one = 1
# You can also create a non-synchronized hashtable, and that will work too. (i.e. Can be used to share state across runspaces)
$hash = [hashtable]::new()
$hash.one = 1
# Runspace One
$rs1 = [System.Management.Automation.Runspaces.RunspaceFactory]::CreateRunspace()
$rs1.open()
$rs1.SessionStateProxy.SetVariable('Hash',$hash)
# Powershell Instance One
$ps1 = [powershell]::Create()
$ps1.runspace = $rs1
$ps1.AddScript(
{$hash.one++}
)
# ScriptBlock which will execute the PS Instance ONE
$sb1 = {
$hash.one
$ps1.BeginInvoke()
}
# Runspace Two
$rs2 = [System.Management.Automation.Runspaces.RunspaceFactory]::CreateRunspace()
$rs2.open()
$rs2.SessionStateProxy.SetVariable('Hash',$hash)
# Powershell Instance Two
$ps2 = [powershell]::Create()
$ps2.runspace = $rs2
$ps2.AddScript(
{$hash.one++}
)
# ScriptBlock which will execute the PS Instance TWO
$sb2= {
$hash.one
$ps2.BeginInvoke()
}
# Hash Value Before executing the PS Instance
$hash.one
# Call the scriptblock ONE, which executes Instance PS1 for RS1
& $sb1
$hash.one
# Call the scriptblock TWO, which executes Instance PS2 for RS2
& $sb2
$hash.one
|
PowerShellCorpus/GithubGist/zhujo01_fef2a32a5a031ab7505f_raw_7cddae3ec81461ba92c45058abb41f6fef7d5470_openstack-vmware.ps1
|
zhujo01_fef2a32a5a031ab7505f_raw_7cddae3ec81461ba92c45058abb41f6fef7d5470_openstack-vmware.ps1
|
########################################################################
# Openstack Windows Bootstrapping Script
# Supported OS:
# - Windows 2008 Server R2 SP1 (TESTED)
# - Windows 2008 Server (TO BE TESTED)
# - Windows 2012 Server (TO BE TESTED)
# Image Transformation Target Cloud
# - VMWare vSphere & VCD
#
# Coppyright (c) 2014, CliQr Technologies, Inc. All rights reserved.
########################################################################
|
PowerShellCorpus/GithubGist/wormeyman_d4fff00ccf57713fabbc_raw_d75e139b3ebcabf7b15f9fe2c2427f5329a9af9e_enableAdmin.ps1
|
wormeyman_d4fff00ccf57713fabbc_raw_d75e139b3ebcabf7b15f9fe2c2427f5329a9af9e_enableAdmin.ps1
|
# Run this command in an elevated (PowerShell) prompt.
# You may have to run the commands in reverse order.
# The first command activates the admin account
net user administrator /active:yes
# The second command gives it the password of "pass" without the quotes
net user administrator pass
|
PowerShellCorpus/GithubGist/nmische_4657161_raw_1bd5f51db70e1c78e787c749a1e5f816a678352b_SetACL.ps1
|
nmische_4657161_raw_1bd5f51db70e1c78e787c749a1e5f816a678352b_SetACL.ps1
|
# This script allows Powershell Session Users to access services remotely
# Get Powershell Session Users SID
$objUser = New-Object System.Security.Principal.NTAccount("Powershell Session Users")
$strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier])
# Get Current ACL for scmanager
$strOldACL = sc.exe sdshow scmanager | Out-String
# Find the ACL for interactive users
$strOldACL -cmatch "\(A;;\w*;;;IU\)"
# Build ACL for Powershell Session Users
$strPSUACL = $Matches[0] -creplace "IU", $strSID.Value.ToString().Trim()
# Make sure ACL for Powershell Session Users isn't already set
if ( $strOldACL -match $strPSUACL ) {
# ACL is good
"SDDL for scmanager $strOldACL already contains $strPSUACL"
} else {
# Update the ACL
$strNewACL = $strOldACL -creplace "\(A;;\w*;;;IU\)", ( $Matches[0].ToString().Trim() + $strPSUACL.ToString().Trim() ) | Out-String -Width 500
"Setting SDDL for scmanager to $strNewACL"
& sc.exe sdset scmanager $strNewACL.ToString().Trim()
}
|
PowerShellCorpus/GithubGist/bbenoist_ca65b602c41db5f2408d_raw_9817a5f741caa8dd617c7a1f1e591cbf8e6382d9_chocolateyInstall.ps1
|
bbenoist_ca65b602c41db5f2408d_raw_9817a5f741caa8dd617c7a1f1e591cbf8e6382d9_chocolateyInstall.ps1
|
try {
$packageName = 'VisualStudio2012WDX'
$setupFile="$env:temp\wdexpress_full.exe"
Get-ChocolateyWebFile "$packageName" "$setupFile" 'http://go.microsoft.com/?linkid=9816758' -checksum '6EEDE869379658DCC025E0FCD17BC2F8' -checksumType 'md5'
Install-ChocolateyInstallPackage "$packageName" 'exe' "/Passive /NoRestart /Log $env:temp\wdexpress_full.log" "$setupFile"
Write-ChocolateySuccess "$packageName"
} catch {
Write-ChocolateyFailure "$packageName" "$($_.Exception.Message)"
throw
}
|
PowerShellCorpus/GithubGist/danielmoore_837193_raw_dd94dbe2c701da011da3eee71e7ad9d47ab8390d_git_svn_ps_prompt.ps1
|
danielmoore_837193_raw_dd94dbe2c701da011da3eee71e7ad9d47ab8390d_git_svn_ps_prompt.ps1
|
Get-ChildItem $psScriptRoot -filter *.ps1 | foreach { . $_.FullName }
if(Get-Module prompt) { Remove-Module prompt }
$prompt_kind = if($args[0]) { $args[0] } else { "bash" }
if($prompt_kind -eq "bash") {
function prompt {
writeUserLocation
Write-Host("`n$") -nonewline -foregroundcolor Green
return " "
}
}
elseif($prompt_kind -eq "svn") {
function prompt {
writeUserLocation
if(Test-Path .svn) {
writeSvnInfo
}
Write-Host("`n$") -nonewline -foregroundcolor Green
return " "
}
}
elseif($prompt_kind -eq "git") {
$env:path += ';{0};{1}' -f (join-path ${env:programfiles(x86)} 'Git/bin'), (join-path ${env:programfiles(x86)} 'Git/cmd')
function prompt {
writeUserLocation
if (isCurrentDirectoryGitRepository) {
writeGitInfo
}
Write-Host("`n$") -nonewline -foregroundcolor Green
return " "
}
}
else { Write-Host "Unknown prompt kind: $prompt_kind" }
function writeUserLocation {
Write-Host($pwd) -nonewline -foregroundcolor Green
}
function writeShortenedUserLocation {
$path = ""
$pathbits = ([string]$pwd).split("\", [System.StringSplitOptions]::RemoveEmptyEntries)
if($pathbits.length -eq 1) {
$path = $pathbits[0] + "\"
} else {
$path = $pathbits[$pathbits.length - 1]
}
$userLocation = $env:username + '@' + [System.Environment]::MachineName + ' ../' + $path
$host.UI.RawUi.WindowTitle = $userLocation
Write-Host($userLocation) -nonewline -foregroundcolor Green
}
function writeGitInfo {
$status = gitStatus
$currentBranch = $status["branch"]
Write-Host(' [') -nonewline -foregroundcolor Yellow
if ($status["ahead"] -eq $FALSE) {
# We are not ahead of origin
Write-Host($currentBranch) -nonewline -foregroundcolor Cyan
} else {
# We are ahead of origin
Write-Host($currentBranch) -nonewline -foregroundcolor Red
}
Write-Host(' +' + $status["added"]) -nonewline -foregroundcolor Yellow
Write-Host(' ~' + $status["modified"]) -nonewline -foregroundcolor Yellow
Write-Host(' -' + $status["deleted"]) -nonewline -foregroundcolor Yellow
if ($status["untracked"] -ne $FALSE) {
Write-Host(' !') -nonewline -foregroundcolor Yellow
}
Write-Host(']') -nonewline -foregroundcolor Yellow
}
function writeSvnInfo {
$untracked=$deleted=$added=$modified=0
switch -regex (svn st) {
"^\?" {$untracked+=1}
"^D" {$deleted+=1}
"^A" {$added+=1}
"^M" {$modified+=1}
}
$prompt_string = " [svn +$added ~$modified -$deleted"
if ($untracked -eq 0) {
$prompt_string += "]"
}
else {
$prompt_string += " !]"
}
Write-Host ($prompt_string) -nonewline -foregroundcolor yellow
}
|
PowerShellCorpus/GithubGist/jpoehls_1478380_raw_a124decc685dedd80e8f0ebbf548c7b65bd66c55_Elevate-Process.ps1
|
jpoehls_1478380_raw_a124decc685dedd80e8f0ebbf548c7b65bd66c55_Elevate-Process.ps1
|
# Put this in your PowerShell profile.
function Elevate-Process
{
<#
.SYNOPSIS
Runs a process as administrator. Stolen from http://weestro.blogspot.com/2009/08/sudo-for-powershell.html.
#>
$file, [string]$arguments = $args
$psi = New-Object System.Diagnostics.ProcessStartInfo $file
$psi.Arguments = $arguments
$psi.Verb = "runas"
$psi.WorkingDirectory = Get-Location
[System.Diagnostics.Process]::Start($psi) | Out-Null
}
Set-Alias sudo Elevate-Process
|
PowerShellCorpus/GithubGist/starkfell_4182813_raw_cfccbfb487a67e3fa50ba1be1423f1d9f23614e2_SCOM_Mon_Query.ps1
|
starkfell_4182813_raw_cfccbfb487a67e3fa50ba1be1423f1d9f23614e2_SCOM_Mon_Query.ps1
|
#################################################################################
#
# [SCOM_Mon_Query.ps1] - SCOM 2012 - Agent Monitoring Query Tool
#
# Author: Ryan Irujo
#
# Inception: 11.26.2012
# Last Modified: 11.30.2012
#
# Syntax: ./SCOM_Mon_Query.ps1 <hostname>
#
# Script is HEAVILY in progress....you have been warned.
#
#
#################################################################################
param($HostName)
Clear-Host
if($HostName -eq $null) {echo "Type in the Name of a Host!!!" ; exit 2}
#QUERY ORDER = Host THEN MPs THEN Monitors THEN Overrides THEN Whatever.....
$ErrArray = @()
$MPClassID_1 = @()
$MPFullName_1 = @()
$MPRules_1 = @()
# ----- Querying SCOM Monitoring Objects based on HostName. -----
$MonObjects = Get-SCOMMonitoringObject | Where-Object {$_.DisplayName -match "$($HostName)"}
ForEach ($MP in $MonObjects){
$MPClassID = $MP.get_LeastDerivedNonAbstractManagementPackClassId()
$MPFullNameQuery = $MP.get_FullName().ToString()
$MPFullNameTrim = $MPFullNameQuery.IndexOf(":")
$MPFullName = $MPFullNameQuery.Substring(0,$MPFullNameTrim)
$MPClassID_1 += "$($MPClassID)"
$MPFullName_1 += "$($MPFullName)"
echo "$($HostName) => MP Class IDs = $($MPClassID) => MPs = $($MPFullName)"
}
# ----- Querying SCOM Monitors based upon previously found Least Derived Non Abstract Management Pack Class ID. -----
ForEach ($GUID in $MPClassID_1){
$MP_Monitors = Get-SCOMMonitor | Where-Object {$_.Target -match $GUID }
Foreach ($Monitor in $MP_Monitors) {
$MPUniqueUIDQuery = $Monitor.get_Target().ToString()
$MPUniqueUIDTrim = $MPUniqueUIDQuery.IndexOf("=")
$MPUniqueUID = $MPUniqueUIDQuery.SubString($MPUniqueUIDTrim).Trim("=")
$MP_MonitorName = $Monitor.get_Name()
$Monitor_Enabled = $Monitor.get_Enabled()
$Monitor_Status = $Monitor.get_Status()
echo "MON:MP UID = $($MPUniqueUID) => Enabled? = $($Monitor_Enabled) FOR => $($MP_MonitorName)"
}
}
# ----- Quering SCOM Rules based upon previously found Least Derived Non Abstract Management Pack Class ID. Again.... -----
ForEach ($GUID in $MPClassID_1){
$MP_Rules = Get-SCOMRule | Where-Object {$_.Target -match $GUID }
try {
Foreach ($Rule in $MP_Rules) {
$MP_RuleTargetQuery = $Rule.get_Target().ToString()
$MP_RuleTargetTrim = $MP_RuleTargetQuery.IndexOf("=")
$MP_RuleTarget = $MP_RuleTargetQuery.SubString($MP_RuleTargetTrim).Trim("=")
$MP_RuleEnabled = $Rule.get_Enabled()
$MP_RuleDisplayName = $Rule.get_DisplayName()
echo "RULES:MP UID = $($MP_RuleTarget) => Enabled? = $($MP_RuleEnabled) FOR => $($MP_RuleDisplayName)"
}
}
catch {
if ([System.Management.Automation.RuntimeException]) {continue}
}
}
|
PowerShellCorpus/GithubGist/jeffpatton1971_368fec5b8eff9e1f1891_raw_29abd7b2794c91acb1a2119d5c48b2b754ebc73d_Sample-NetActivity.ps1
|
jeffpatton1971_368fec5b8eff9e1f1891_raw_29abd7b2794c91acb1a2119d5c48b2b754ebc73d_Sample-NetActivity.ps1
|
#
# Enable-WSManCredSSP -Role Client -DelegateComputer localhost
# Enable-WSManCredSSP -Role Server
#
Try{
$ErrorActionPreference = "Stop";
$WinRMUser = "\`d.T.~Ed/{34846A7C-5BC4-4C23-A22A-D21C1DC99DF8}.{5408AD4E-3052-4F73-B45E-7DADBB999FE4}\`d.T.~Ed/";
$WinRMPass = ConvertTo-SecureString -String "\`d.T.~Ed/{34846A7C-5BC4-4C23-A22A-D21C1DC99DF8}.{98301C29-F4AF-4A43-88D3-851520744C6B}\`d.T.~Ed/" -AsPlainText -Force;
$Credential = New-Object System.Management.Automation.PSCredential ($WinRMUser, $WinRMPass);
#
# We will connect to and run powershell from the local orchestrator server
#
$ComputerName = "\`d.T.~Ed/{34846A7C-5BC4-4C23-A22A-D21C1DC99DF8}.{B0699ECA-EA8F-40B6-A73F-00D220D955C6}\`d.T.~Ed/";
#
# Pass these into invoke
#
$AdsPath = "\`d.T.~Ed/{34846A7C-5BC4-4C23-A22A-D21C1DC99DF8}.{332FD283-912F-431C-A481-26433B5FB78D}\`d.T.~Ed/";
$SearchFilter = "\`d.T.~Ed/{34846A7C-5BC4-4C23-A22A-D21C1DC99DF8}.{401BF2E1-D1CF-4650-A9D4-22E6955B547F}\`d.T.~Ed/";
#
# The following two modules are my custom modules for working with AD and text logfiles
#
$LogModulePath = "\`d.T.~Ed/{34846A7C-5BC4-4C23-A22A-D21C1DC99DF8}.{C230740F-832C-44D8-A496-D4BBD86018B0}\`d.T.~Ed/";
$ADModulePath = "\`d.T.~Ed/{34846A7C-5BC4-4C23-A22A-D21C1DC99DF8}.{2652BC51-9A85-45C3-ADD8-8A9FF7FB92E7}\`d.T.~Ed/";
#
# Set this to be the location of your logfiles, if you leave it blank the functions will create C:\Logfiles and store them there
#
$LogPath = "\`d.T.~Ed/{34846A7C-5BC4-4C23-A22A-D21C1DC99DF8}.{2563F269-803F-4855-A3D2-198BCDDEEB07}\`d.T.~Ed/";
#
# A descriptive name that will become the logfile
#
$LogName = "";
#
# Add whatever variablese you need here
#
New-EventLog -LogName "Windows PowerShell" -Source $LogName -ErrorAction SilentlyContinue
$Session = New-PSSession -ComputerName $ComputerName -Credential $Credential -Authentication Credssp
#
# Whatever additional variables you add above, make sure to add them to the argumentlist below
#
Invoke-Command -Session $Session -ArgumentList $AdsPath, $SearchFilter, $LogModulePath, $ADModulePath, $LogPath, $LogName -ScriptBlock{
#
# Param == Argumentlist check your work here
#
Param ($AdsPath, $SearchFilter, $LogModulePath, $ADModulePath, $LogPath, $LogName)
try{
Import-Module $LogModulePath;
Import-Module $ADModulePath;
#
# Import any other required modules here
#
#
# Start the work
#
Write-LogFile -LogPath $LogPath -LogName $LogName -Source "Execution" -EventID 100 -EntryType "Information" -Message "Begin Office 365 Provisioning";
#
# End the work
#
Write-LogFile -LogPath $LogPath -LogName $LogName -Source "Execution" -EventID 100 -EntryType "Information" -Message "End Office 365 Provisioning";
}
catch{
#
# This catch handles any errors that may occur inside the session
#
Write-EventLog -LogName 'Windows PowerShell' -EntryType Error -Source $LogName -EventId 2 -Message (ConvertTo-Xml -InputObject $Error[0].InvocationInfo).InnerXml;
Write-EventLog -LogName 'Windows PowerShell' -EntryType Error -Source $LogName -EventId 2 -Message $Error[0].Exception;
}
}
}
catch{
#
# You may need to hardcode your logname here, this catch handles any connection errors that may occur
#
Write-EventLog -LogName 'Windows PowerShell' -EntryType Error -Source $LogName -EventId 1 -Message (ConvertTo-Xml -InputObject $Error[0].InvocationInfo).InnerXml;
Write-EventLog -LogName 'Windows PowerShell' -EntryType Error -Source $LogName -EventId 1 -Message $Error[0].Exception;
}
|
PowerShellCorpus/GithubGist/virtualdreams_a25b9130f2fc2a846cd6_raw_787f0ced27b178b94faf6d8bf33806e88ac1ba73_build.ps1
|
virtualdreams_a25b9130f2fc2a846cd6_raw_787f0ced27b178b94faf6d8bf33806e88ac1ba73_build.ps1
|
param
(
[string]$file
)
if(!$file)
{
Write-Host "Path is not set."
return
}
if(!(Test-Path $file))
{
Write-Host "Path not found."
return
}
### pattern to search
$pattern = "\[assembly: AssemblyFileVersion\(""(\d+)\.(\d+)\.(\d+)\.(\d+)\""\)\]"
$update = $false
$content = Get-Content $file -Encoding UTF8
$replace = @()
foreach($line in $content) {
if($line -match $pattern) {
$major = [int]$matches[1]
$minor = [int]$matches[2]
$build = [int]$matches[3]
$revision = [int]$matches[4]
$build = $build + 1
$line = "[assembly: AssemblyFileVersion(""{0}.{1}.{2}.{3}"")]" -f $major, $minor, $build, $revision
Write-Host([string]::Format("Version number updated to ""{0}.{1}.{2}.{3}""", $major, $minor, $build, $revision))
$update = $true
}
$replace += [Array]$line
}
### update only if pattern found
if($update -eq $true)
{
$replace | Out-File $file -Encoding UTF8 -force
}
|
PowerShellCorpus/GithubGist/guitarrapc_945408f9bd94e7a8f108_raw_89863221c918032dcc5f1747d8962cc5c5399b21_Remove-Office365LisenceFromUser.ps1
|
guitarrapc_945408f9bd94e7a8f108_raw_89863221c918032dcc5f1747d8962cc5c5399b21_Remove-Office365LisenceFromUser.ps1
|
function Remove-Office365LicenseFromUser
{
[CmdletBinding()]
param
(
[Parameter(Position = 0, Mandatory = 1, HelpMessage = "Pass MsolUser Objects.")]
[Microsoft.Online.Administration.User[]]$users
)
begin
{
$ErrorActionPreference = "Stop"
# get sku
$accountSkuId = (Get-MsolAccountSku).AccountSkuId
}
process
{
try
{
# remove License to user
foreach ($user in $users)
{
Write-Warning ("Removing Office365 License '{0}' from user '{1}'" -f $accountSkuId, $user.UserPrincipalName)
Set-MsolUserLicense -UserPrincipalName $user.UserPrincipalName -RemoveLicenses $accountSkuId
}
}
catch
{
Write-Error $_
}
}
}
|
PowerShellCorpus/GithubGist/mcollier_5749396_raw_14efdd0cedb80472789373dc9b01ab1526246a0c_teched_na_2013_downloads.ps1
|
mcollier_5749396_raw_14efdd0cedb80472789373dc9b01ab1526246a0c_teched_na_2013_downloads.ps1
|
cls
[Environment]::CurrentDirectory=(Get-Location -PSProvider FileSystem).ProviderPath
$rss = (new-object net.webclient)
#Set the username for windows auth proxy
#$rss.proxy.credentials=[system.net.credentialcache]::defaultnetworkcredentials
# TechEd NA 2013
#$dataFeed = "http://channel9.msdn.com/Events/TechEd/NorthAmerica/2013/rss/mp4high/?sort=sequential&direction=desc&term=&r=Developer+Tools+%26+Application+Lifecycle+Management&r=Windows+Azure+Application+Development&y=Breakout&Media=true#fbid=FDnmapgI5Hf"
# TechEd NA 2013 - All
#$dataFeed = "http://channel9.msdn.com/Events/TechEd/NorthAmerica/2013/RSS/mp4high"
#TechEd NA 2013 - Windows Azure
#$dataFeed = "http://channel9.msdn.com/Events/TechEd/NorthAmerica/2013/rss/mp4high/?sort=sequential&direction=desc&term=&r=Windows+Azure+Application+Development&y=Breakout&Media=true#fbid=FDnmapgI5Hf"
# TechEd Europe 2013 - All
#$dataFeed = "http://channel9.msdn.com/Events/TechEd/Europe/2013/RSS/mp4high"
# TechEd Europe 2013 - Windows Azure
#$dataFeed = "http://channel9.msdn.com/Events/TechEd/europe/2013/RSS/mp4high/?sort=sequential&direction=desc&term=&r=Windows+Azure+Application+Development&y=Breakout&Media"
#BUILD 2013 - All
$dataFeed = "http://channel9.msdn.com/Events/Build/2013/RSS/mp4high#theSessions"
$a = ([xml]$rss.downloadstring($dataFeed))
$a.rss.channel.item | foreach{
$mediaUrl = New-Object System.Uri($_.enclosure.url)
$pptxUrl = New-Object System.Uri($_.enclosure.url.Replace(".mp4", ".pptx"))
$file = $_.creator + " - " + $_.title.Replace(":", "-").Replace("?", "").Replace("/", "-").Replace("<", "-") + ".mp4"
$pptx = $_.creator + " - " + $_.title.Replace(":", "-").Replace("?", "").Replace("/", "-").Replace("<", "-") + ".pptx"
if ($_.category -eq "windows-azure")
{
if (!(test-path $file))
{
$file
$wc = (New-Object System.Net.WebClient)
#Set the username for windows auth proxy
#$wc.proxy.credentials=[system.net.credentialcache]::defaultnetworkcredentials
$wc.DownloadFile($mediaUrl, $file)
}
if (!(test-path $pptx))
{
$pptx
$wc = (New-Object System.Net.WebClient)
#Set the username for windows auth proxy
#$wc.proxy.credentials=[system.net.credentialcache]::defaultnetworkcredentials
$wc.DownloadFile($pptxUrl, $pptx)
}
}
}
|
PowerShellCorpus/GithubGist/andreaswasita_96290d29994d5e251b33_raw_4a5629103a3f5d6146b9e4fc97da3403be146bfc_TechEdILB%20Step%201.ps1
|
andreaswasita_96290d29994d5e251b33_raw_4a5629103a3f5d6146b9e4fc97da3403be146bfc_TechEdILB%20Step%201.ps1
|
$svc="techedadfs"
$ilb="adfsilb"
$subnet="App Subnet"
$IP="10.0.1.55"
Add-AzureInternalLoadBalancer -ServiceName $svc -InternalLoadBalancerName $ilb –SubnetName $subnet –StaticVNetIPAddress $IP
|
PowerShellCorpus/GithubGist/suzan2go_66289adf0bbf85f3529d_raw_2d671948341f24ab606597a2a3f698bbf8cfff92_get-failoverhost.ps1
|
suzan2go_66289adf0bbf85f3529d_raw_2d671948341f24ab606597a2a3f698bbf8cfff92_get-failoverhost.ps1
|
$Cl = Get-Cluster
$array = New-Object 'System.Collections.Generic.List[System.String]'
#fail over hostが持つIDを$arrrayに格納する。
foreach($a in $array) {
foreach($fh in $a.ExtensionData.Configuration.DasConfig.AdmissionControlPolicy.Failoverhosts){
$array.add($fh)
}
}
# ESXiホスト名 , HAホスト(true or false)で出力する
Get-VmHost | select Name,@{Name="is_fail_over_host";Expression=if($array -contains $_.id){echo $true}else{echo $false}}
|
PowerShellCorpus/GithubGist/wormeyman_443ce904bea86990471a_raw_3c844af67250606af8149efc66ae5da9641bae80_youTubeDLPrompt.ps1
|
wormeyman_443ce904bea86990471a_raw_3c844af67250606af8149efc66ae5da9641bae80_youTubeDLPrompt.ps1
|
# Download the Windows binary: http://rg3.github.io/youtube-dl/download.html
# This script needs to be in the same folder as youtube-dl.exe
# --
# Some websites require FFmpeg binaries to be in the same folder as well.
# http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-latest-win32-static.7z
# --
# Allow powershell scripts:
# Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
# --
# Propt for the video URL
$video = Read-Host 'What is the video url?'
# Update YouTubeDL this prevents any errors if YouTube has made changes.
Write-Host -ForegroundColor Green "Updating YouTube-DL before Downloading"
.\youtube-dl.exe -U
clear
# Download the Video
# The --restrict-filenames gives a nice clean filename and also works better
# with copying and pasting if there is an & in the URL
.\youtube-dl.exe --restrict-filenames $video
# YouTube 60fps support:
# .\youtube-dl.exe -f bestvideo+bestaudio --restrict-filenames $video
Write-Host -ForegroundColor Green "The Script has Finished!"
Write-Host -ForegroundColor Green "Opening Video Folder."
Invoke-Item $PWD
|
PowerShellCorpus/GithubGist/sandrinodimattia_4214953_raw_10075a61fb32d94137900457c6e38850063eba42_gistfile1.ps1
|
sandrinodimattia_4214953_raw_10075a61fb32d94137900457c6e38850063eba42_gistfile1.ps1
|
$user = Get-WMIObject Win32_UserAccount -Filter "Name='Administrator'"
$username = -join ([Char[]]'abcdefghijklmnopqrstuvwxyz._-~´`àéèç' | Get-Random -count 15)
$user.Rename($username)
|
PowerShellCorpus/GithubGist/wintlu_4cd53a0c15a0b9953b10_raw_a8c5d7682ecf721f94e08e6531d1851a2392ec44_FillBudgetHeadCountPayrollInput.ps1
|
wintlu_4cd53a0c15a0b9953b10_raw_a8c5d7682ecf721f94e08e6531d1851a2392ec44_FillBudgetHeadCountPayrollInput.ps1
|
#$web = Get-SPWeb "http://portal.delta-corp.com/sites/MyDelta/BPP"
Function ReadBudgetHeadCount()
{
$bList = $web.Lists["Budget HeadCount"]
$m = @{}
foreach($i in $bList.Items){
$key = $i["Job Sub Function"] + "-" + $i["Job Grade"]
if(!$m.ContainsKey($key)){
$initHeadCount = [double]$i["Head Count"]
$m[$key] = @{"Job Sub Function"= $i["Job Sub Function"]; "Job Grade"= $i["Job Grade"]; "Head Count"=$initHeadCount}
}else {
$v = $m[$key]
$v["Head Count"] += [double]$i["Head Count"]
}
}
return $m
}
Function FillBudgetHeadCountPayrollInput($m, $minimalSalary)
{
$list = $web.Lists["Budget HeadCount Payroll Input"]
$stamp = Get-Date
foreach($key in $m.Keys)
{
$item = $list.AddItem()
$v = $m[$key]
$item["Job Sub Function"] = $v["Job Sub Function"]
$item["Job Grade"] = $v["Job Grade"]
$item["Sum Headcount"] = $v["Head Count"]
if($minimalSalary.ContainsKey($key)){
$item["Medium Salary per Headcount"] = $minimalSalary[$key]
}
$item["Title"] = $stamp.Ticks
$item.Update()
}
}
Function ReadMinimalSalary
{
$list = $web.Lists["Medium Salary per Headcount"]
$ms = @{}
foreach($item in $list.Items)
{
$key = $item["Job Sub Function"] + "-" + $item["Job Grade"]
$ms[$key]=$item["Salary"]
}
return $ms
}
$minimalSalary = ReadMinimalSalary
$m = ReadBudgetHeadCount
FillBudgetHeadCountPayrollInput $m $minimalSalary
|
PowerShellCorpus/GithubGist/bill-long_8810381_raw_de92cc9ac0178f998547c214734ad5daa3800f0f_Fix-DelegatedSetup.ps1
|
bill-long_8810381_raw_de92cc9ac0178f998547c214734ad5daa3800f0f_Fix-DelegatedSetup.ps1
|
# Fix-DelegatedSetup.ps1
#
# In Exchange 2013, delegated setup fails if legacy admin groups still exist. However,
# it's recommended that these admin groups not be deleted. To make delegated setup work,
# you can temporarily place an explicit deny so that the Delegated Setup group
# cannot see them. This script automates that process.
#
# This script takes no parameters. The syntax is simply:
# .\Fix-DelegatedSetup.ps1
#
# The script will add the explicit deny if it is not present, and it will remove it
# if it is present. This means you simply run the script to add the deny, perform
# the delegated setup, and then run the script again to remove the deny.
$delegatedSetupRoleGroup = Get-RoleGroup "Delegated Setup"
if ($delegatedSetupRoleGroup -eq $null)
{
"Could not get Delegated Setup role group."
return
}
$rootDSE = [ADSI]("LDAP://RootDSE")
if ($rootDSE.configurationNamingContext -eq $null)
{
"Could not read RootDSE."
return
}
$adminGroupFinder = new-object System.DirectoryServices.DirectorySearcher
$adminGroupFinder.SearchRoot = [ADSI]("LDAP://" + $rootDSE.configurationNamingContext.ToString())
$adminGroupFinder.Filter = "(&(objectClass=msExchAdminGroup)(!(cn=Exchange Administrative Group (FYDIBOHF23SPDLT))))"
$adminGroupFinder.SearchScope = "Subtree"
$adminGroupResults = $adminGroupFinder.FindAll()
if ($adminGroupResults.Count -lt 1)
{
"No legacy admin groups were found."
return
}
# Check to see if we already have the explicit perms set
$foundExplicitPerms = $false
foreach ($result in $adminGroupResults)
{
$explicitPerms = Get-ADPermission $result.Properties["distinguishedname"][0].ToString() | `
WHERE { $_.IsInherited -eq $false -and $_.Deny -eq $true -and $_.User -like "*\Delegated Setup" }
if ($explicitPerms.Length -gt 0)
{
$foundExplicitPerms = $true
break
}
}
if ($foundExplicitPerms)
{
# We already have explicit perms on at least some legacy admin groups, so
# remove them from all admin groups where they exist
"Removing explicit deny for Delegated Setup..."
foreach ($result in $adminGroupResults)
{
$explicitPerms = Get-ADPermission $result.Properties["distinguishedname"][0].ToString() | `
WHERE { $_.IsInherited -eq $false -and $_.Deny -eq $true -and $_.User -like "*\Delegated Setup" }
if ($explicitPerms.Length -gt 0)
{
foreach ($perm in $explicitPerms)
{
Remove-ADPermission -Instance $perm -Confirm:$false
}
}
}
}
else
{
# We don't have explicit perms on any legacy admin groups, so add them to
# all legacy admin groups
"Adding explicit deny for Delegated Setup..."
foreach ($result in $adminGroupResults)
{
Add-ADPermission $result.Properties["distinguishedname"][0].ToString() `
-User $delegatedSetupRoleGroup.DistinguishedName -Deny -AccessRights GenericAll | out-null
}
}
|
PowerShellCorpus/GithubGist/mrlesmithjr_7954840_raw_97eec2a89db151329f3d8b0fbdbf4f1b86a16163_get_vmhost_net.ps1
|
mrlesmithjr_7954840_raw_97eec2a89db151329f3d8b0fbdbf4f1b86a16163_get_vmhost_net.ps1
|
#Provided by @mrlesmithjr
#EveryThingShouldBeVirtual.com
#
# Set variable for all hosts in current vCenter
$vmhosts = @(Get-VMHost)
foreach ($vmhost in $vmhosts) {
Get-NetworkAdapter $vmhost
}
|
PowerShellCorpus/GithubGist/hobelinm_9456238_raw_fc22e1171c4cf4417787e3ebc180bb0d72f201af_DynamicLoadingTest.ps1
|
hobelinm_9456238_raw_fc22e1171c4cf4417787e3ebc180bb0d72f201af_DynamicLoadingTest.ps1
|
# Considering the test function in a given location
# you can ignore the following line
"function test{""Original Test""}" > test.ps1
# This is a sample of the stub that would peform the function of
# finding and downloading the original function. For the sake of
# the test we can consider that's already done in test.ps1 in $PWD
function test
{
"Stub Test"
# Future calls will go to the original test method and not this stub
Remove-Item function:test
# Replace this line for finding-loading-installing locally
Import-Module .\test.ps1 -Global
# Since the intended call was to the original function, call it
test
}
|
PowerShellCorpus/GithubGist/philipmat_9273405_raw_115dc9cf992324419ce33272fa786b5a07930f88_Microsoft.PowerShell_profile.ps1
|
philipmat_9273405_raw_115dc9cf992324419ce33272fa786b5a07930f88_Microsoft.PowerShell_profile.ps1
|
function Get-URL([string] $url) {
(New-Object net.webclient).DownloadString($url)
}
|
PowerShellCorpus/GithubGist/gshiva_c6048173763abbbef88a_raw_4e570ba3776c2cf9e0398c47e28b0b3270a63b55_testps.ps1
|
gshiva_c6048173763abbbef88a_raw_4e570ba3776c2cf9e0398c47e28b0b3270a63b55_testps.ps1
|
cinst git
echo "Hello"
|
PowerShellCorpus/GithubGist/kyam_5575898_raw_8ef8db78d4b33558dd7dd3065a02263049b9bca0_Listed_InstalledApps.ps1
|
kyam_5575898_raw_8ef8db78d4b33558dd7dd3065a02263049b9bca0_Listed_InstalledApps.ps1
|
# Mapping Registry
$InstalledApplicationRegistry = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall"
New-PSDrive -Name Uninstall -PSProvider Registry -Root $InstalledApplicationRegistry
ls Uninstall:
Remove-PSDrive -Name Uninstall # remove Uninstall:
|
PowerShellCorpus/GithubGist/vScripter_10901166_raw_1dbf38c80799848e41f85bf953f22717a7de2dac_Get-ProcessorInventory.ps1
|
vScripter_10901166_raw_1dbf38c80799848e41f85bf953f22717a7de2dac_Get-ProcessorInventory.ps1
|
<#
.SYNOPSIS
Returns information about the Processor via WMI.
.DESCRIPTION
Information about the processor is returned using the Win32_Processor WMI class.
You can provide a single computer/server name or supply an array/list.
.PARAMETER Computers
Single computer name, list of computers or .txt file containing a list of computers.
.EXAMPLE
.\Get-ProcessorInventory.ps1 -Computers (Get-Content C:\ComputerList.txt)
.EXAMPLE
.\Get-ProcessorInventory.ps1 -Computers Test-Server.company.com
.EXAMPLE
.\Get-ProcessorInventory.ps1 -Computers SERVER1.company.com,SERVER2.company.com | Format-Table -AutoSize
.EXAMPLE
.\Get-ProcessorInventory.ps1 -Computers SERVER1.company.com,SERVER2.company.com | Export-Csv C:\ProcInv.csv -NoTypeInformation
.INPUTS
System.String
.OUTPUTS
Selected.System.Management.ManagementObject
.NOTES
#=======================================================
Author: Kevin Kirkpatrick
Created: 4/16/14
Disclaimer: This script comes with no implied warranty or guarantee and is to be used at your own risk. It's recommended that you TEST
execution of the script against Dev/Test before running against any Production system.
#========================================================
.LINK
https://github.com/vN3rd/PowerShell-Scripts
.LINK
about_WMi
.LINK
about_Wmi_Cmdlets
#>
#Requires -Version 3
[cmdletbinding()]
Param (
[parameter(Mandatory = $true,
ValueFromPipeline = $true,
HelpMessage = "Enter the name of a computer or an array of computer names")]
[system.string[]]$Computers
)
# Set the EA preference to 'Stop' so that Non-Terminating errors will be caught and displayed in the catch block
$ErrorActionPreference = "Stop"
# Cycle through each computer and attempt to query WMI
foreach ($C in $Computers)
{
# Test the connection to the computer, if it pings, continue on with the query
if (Test-Connection -ComputerName $C -Count 1 -Quiet)
{
try
{
#region FormattingHashTables
#================================
# Attempt to differentiate if the destination is a VM, or not. In VMware, vProcessors typically return a value of 0 for the L2 Processor Cache.
# This was not testing with Hyper-V
$Type = @{
label = 'Type'
expression = {
if ($_.L2CacheSize -eq '0') { "Virtual" }
else { "Physical" }
}
}# end $Type
# Check to see if HyperThreading is enabled by comparing the number of logical processors with the number of cores
$HyperThreading = @{
label = 'HyperthreadingEnabled'
expression = {
if ($_.NumberOfLogicalProcessors -gt $_.NumberOfCores) { "Yes" }
else { "No" }
}
}# end $HyperThreading
# Use hash tables to modify the paramter output names
$ComputerName = @{ label = 'Computer'; Expression = { $_.PSComputerName } }
$CoreCount = @{ label = 'CoreCount'; Expression = { $_.NumberOfCores } }
$LogicalCores = @{ label = 'LogicalProcessors'; expression = { $_.NumberOfLogicalProcessors } }
$Description = @{ label = 'Description'; Expression = { $_.Name } }
$Socket = @{ label = 'Socket'; expression = { $_.SocketDesignation } }
#================================
#endregion
# Run the query
Get-WmiObject -Query "SELECT * FROM win32_processor" -ComputerName $C |
Select-Object $ComputerName, $Socket, $CoreCount, $LogicalCores, $HyperThreading, $Description, $Type
}# end try
catch
{
# Catch any errors and write a warning that includes the computer name as well as the error message, which is stored in $_
Write-Warning "$C - $_"
}# end catch
}# end if
else
{
# If the computer was not reachable on the network, display such detail
Write-Warning "$C is unreachable"
}# end else
}# end foreach
|
PowerShellCorpus/GithubGist/astaykov_c68bc86f43ba28163312_raw_6d367f68e5cb005f3d7d5e2fb223b13ce75709f1_AzureCloudServiceAntiMalwareProtection.ps1
|
astaykov_c68bc86f43ba28163312_raw_6d367f68e5cb005f3d7d5e2fb223b13ce75709f1_AzureCloudServiceAntiMalwareProtection.ps1
|
Add-AzureAccount
# use Select-AzureSubscription in case your account has more than one
Select-AzureSubscription -SubscriptionName 'PUT HERE YOUR SUBSCRIPTION'
[System.Xml.XmlDocument] $XmlConfig = New-Object System.Xml.XmlDocument
# load the Antimalware extension configuration from external XML file
# The content of the XML needs to be:
# <AntimalwareConfig><AntimalwareEnabled>true</AntimalwareEnabled></AntimalwareConfig>
# ref.: http://msdn.microsoft.com/en-US/library/azure/dn771718
$XmlConfig.load('D:\tmp\AntiMalware.config')
Set-AzureServiceAntimalwareExtension -ServiceName "PUT HERE THE CLOUD SERVICE NAME" -AntimalwareConfiguration $XmlConfig
|
PowerShellCorpus/GithubGist/shiftkey_2916215_raw_fdc80f8556380902b6a5f313c1127a2ee962a215_Deployment.ps1
|
shiftkey_2916215_raw_fdc80f8556380902b6a5f313c1127a2ee962a215_Deployment.ps1
|
properties {
$BaseDir = Resolve-Path "..\"
$SolutionFile = "$BaseDir\Cocoon.sln"
$OutputDir = "$BaseDir\Deploy\Package\"
$ArtifactsDir = "$BaseDir\artifacts\"
$NuGetPackDir = Join-Path "$OutputDir" "Pack\"
$Version = "1.0.0." + (git rev-list --all | wc -l).trim() + "-rc" # TODO: better implementation
$Debug="false"
}
function Log-Message ($message) {
write-host $message -foregroundcolor "green"
}
function Set-Version {
param([Parameter(Mandatory=$true)][string]$assembly_info,[Parameter(Mandatory=$true)][string]$Version)
$infile=get-content $assembly_info
$regex = New-Object System.Text.RegularExpressions.Regex "\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b"
$replace = $regex.Replace($infile,$version)
set-content -Value $replace $assembly_info
}
function Create-IfNotFound {
param([Parameter(Mandatory=$true)][string]$Directory)
if ((Test-Path $Directory -PathType Container) -ne $true) {
mkdir $Directory | out-null
}
}
function Clear-Recursively {
param([Parameter(Mandatory=$true)][string]$Directory)
if (Test-Path $Directory -PathType Container) {
ri $Directory -Recurse | out-null
}
}
function Create-Package {
param([Parameter(Mandatory=$true)][string]$PackageName,[Parameter(Mandatory=$true)][string]$TempDir)
Create-IfNotFound $TempDir
Create-IfNotFound $ArtifactsDir
Create-IfNotFound "$TempDir\lib\winrt45\"
$PackageNameFile = "$PackageName.nuspec"
$nuspecFile = "$BaseDir\build\$PackageName\$PackageName.nuspec"
cp $nuspecFile $TempDir
cp "$OutputDir\$PackageName\$PackageName.dll" "$TempDir\lib\winrt45\" # add initial assembly
rm "$OutputDir\$PackageName\Cocoon.*.dll" # remove assemblies available from other Cocoon packages
cp "$OutputDir\$PackageName\*.dll" "$TempDir\lib\winrt45\" # include other binary dependencies
if (Test-Path "$PackageName\tools\") { # import any PS scripts for this package
cp "$PackageName\tools\*" "$TempDir\tools\"
}
Log-Message "Modifying placeholder in nuspec file"
$Spec = [xml](get-content "$TempDir\$PackageNameFile")
$Spec.package.metadata.version = ([string]$Spec.package.metadata.version).Replace("{version}",$Version)
foreach($dependency in $Spec.package.metadata.dependencies.dependency) {
$dependency.version = ([string]$dependency.version).Replace("{version}",$Version)
}
$Spec.Save("$TempDir\$PackageNameFile")
exec { ..\.nuget\NuGet.exe pack "$TempDir\$PackageNameFile" -Output $ArtifactsDir }
Clear-Recursively $TempDir
}
task default -depends package
task clean {
#git checkout -- ..\
#git clean -df ..\
Clear-Recursively $OutputDir
Clear-Recursively $ArtifactsDir
}
task version -depends clean {
Log-Message "Updating version to $version"
foreach ($assemblyinfo in $(get-childitem -Path $BaseDir -Include "AssemblyInfo.cs" -recurse)) {
Set-Version -assembly_info "$assemblyinfo" -Version $Version
}
}
task compile -depends clean,version {
msbuild $SolutionFile "/p:OutDir=$OutputDir" "/p:Configuration=Release" "/verbosity:quiet"
}
task package -depends compile {
Create-Package -PackageName "Cocoon" -TempDir $NuGetPackDir
Create-Package -PackageName "Cocoon.Data" -TempDir $NuGetPackDir
Create-Package -PackageName "Cocoon.MEF" -TempDir $NuGetPackDir
Create-Package -PackageName "Cocoon.Autofac" -TempDir $NuGetPackDir
}
|
PowerShellCorpus/GithubGist/txchen_5287695_raw_4d3e8a1c617a86dbf33203e0b0ed8eaeef119005_parseini.ps1
|
txchen_5287695_raw_4d3e8a1c617a86dbf33203e0b0ed8eaeef119005_parseini.ps1
|
function ParseIni ($filePath)
{
$ini = @{}
switch -regex -file $FilePath
{
"^\[(.+)\]$" # Section
{
$section = $matches[1]
$ini[$section] = @{}
}
"^([^;].*[^\s])\s*=\s*([^\s].*[^\s])$" # Key
{
if (!($section))
{
$section = "No-Section"
$ini[$section] = @{}
}
$name,$value = $matches[1..2]
$ini[$section][$name] = $value
}
}
Return $ini
}
|
PowerShellCorpus/GithubGist/pkirch_058d757a799fa0087241_raw_3a5f97cb62e57537c1036434b6d3bf36045c129f_MVA03-Images.ps1
|
pkirch_058d757a799fa0087241_raw_3a5f97cb62e57537c1036434b6d3bf36045c129f_MVA03-Images.ps1
|
# sample 1
$images = Get-AzureVMImage
$images.Count
$images[0]
# sample 2
$images | Group-Object -Property OS
# sample 3
$images | Group-Object -Property PublisherName | Sort-Object -Property Name | Format-Table -Property Count, Name -AutoSize
# sample 4
$images | Group-Object -Property ImageFamily | Sort-Object -Property Name | Format-Table -Property Count, Name -AutoSize
$images | Where-Object -Property ImageFamily -eq "Windows Server 2012 R2 Datacenter" | Format-List -Property ImageName, Label, PublishedDate
# sample 5
$imageName = Get-AzureVMImage | Where-Object -Property ImageFamily -eq "Windows Server 2012 R2 Datacenter" | Sort-Object -Property PublishedDate -Descending | Select-Object -ExpandProperty ImageName -First 1
$imageName
|
PowerShellCorpus/GithubGist/tanaka-takayoshi_8066817_raw_3be89d9fb2c37178674c3a3af0a07195153455ec_Claudia.ps1
|
tanaka-takayoshi_8066817_raw_3be89d9fb2c37178674c3a3af0a07195153455ec_Claudia.ps1
|
$assemblies = (
"System",
"PresentationCore",
"PresentationFramework",
"System.Windows.Presentation",
"System.Xaml",
"WindowsBase",
"System.Xml"
)
$source = @"
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;
public class Program
{
//もはやSTAThread指定いらなくなった
//[STAThread]
public static void Run(string xaml)
{
var app = new Application();
var window = (Window)XamlReader.Load(new MemoryStream(Encoding.UTF8.GetBytes(xaml)));
app.Run(window);
}
}
"@
$xaml = @"
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="XamClaudiaPS1" Height="350" Width="525">
<Window.Resources>
<LinearGradientBrush x:Key="ブラシ_髪"
EndPoint="0.5,1"
StartPoint="0.5,0">
<GradientStop Color="#FFFEF3BD" />
<GradientStop Color="#FFFEDF93"
Offset="1" />
</LinearGradientBrush>
<Color x:Key="色_髪_輪郭">Black</Color>
<SolidColorBrush x:Key="ブラシ_髪_輪郭"
Color="Black" />
<LinearGradientBrush x:Key="ブラシ_髪_影"
EndPoint="0.5,1"
StartPoint="0.5,0">
<GradientStop Color="#FFDFBE78"
Offset="0" />
<GradientStop Color="#FFDEB86D"
Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="ブラシ_肌"
EndPoint="0.5,1"
StartPoint="0.5,0">
<GradientStop Color="#FFFDEADB"
Offset="1" />
<GradientStop Color="#FFFDEAD9" />
</LinearGradientBrush>
<SolidColorBrush x:Key="ブラシ_肌_影"
Color="#FFF1C6B9" />
<Color x:Key="色_肌_輪郭">Black</Color>
<SolidColorBrush x:Key="ブラシ_肌_輪郭"
Color="Black" />
<LinearGradientBrush x:Key="ブラシ_肌_影2"
EndPoint="0.5,1"
StartPoint="0.5,0">
<GradientStop Color="#FFE1A292" />
<GradientStop Color="#FFEDB9AC"
Offset="1" />
</LinearGradientBrush>
<SolidColorBrush x:Key="ブラシ_セーター"
Color="#FFFEF0D9" />
<SolidColorBrush x:Key="ブラシ_セーター_輪郭"
Color="Black" />
<SolidColorBrush x:Key="ブラシ_セーター_影"
Color="#FFDCC7AC" />
<SolidColorBrush x:Key="ブラシ_シャツ"
Color="White" />
<SolidColorBrush x:Key="ブラシ_シャツ_輪郭"
Color="Black" />
<SolidColorBrush x:Key="ブラシ_影"
Color="#3F000000" />
<SolidColorBrush x:Key="ブラシ_シャツ_影"
Color="#FFD1D2D4" />
<SolidColorBrush x:Key="ブラシ_イヤリング_耳あて"
Color="#FFFFFFFE" />
<SolidColorBrush x:Key="ブラシ_イヤリング_耳あて_輪郭"
Color="Black" />
<RadialGradientBrush x:Key="ブラシ_イヤリング">
<GradientStop Color="#FFD1EAEF"
Offset="0" />
<GradientStop Color="#FF3791CF"
Offset="1" />
</RadialGradientBrush>
<SolidColorBrush x:Key="ブラシ_虹彩"
Color="#FF5BBFB2" />
<SolidColorBrush x:Key="ブラシ_瞳孔"
Color="#FF016B6E" />
<SolidColorBrush x:Key="ブラシ_ハイライト"
Color="White" />
<SolidColorBrush x:Key="ブラシ_瞼"
Color="Black" />
<SolidColorBrush x:Key="ブラシ_虹彩_輪郭"
Color="Black" />
<SolidColorBrush x:Key="ブラシ_瞳_影"
Color="#66000032" />
<SolidColorBrush x:Key="ブラシ_メガネ_フレーム"
Color="#FFBF1B21" />
<LinearGradientBrush x:Key="ブラシ_メガネ_レンズ"
EndPoint="0.5,1"
StartPoint="0.5,0">
<GradientStop Color="#00FFFFFF"
Offset="1" />
<GradientStop Color="#7FFFFFFF"
Offset="0.5" />
</LinearGradientBrush>
<SolidColorBrush x:Key="ブラシ_口"
Color="#FFF4AD9A" />
<LinearGradientBrush x:Key="ブラシ_口_輪郭"
EndPoint="0.5,1"
StartPoint="0.4,0">
<GradientStop Color="Black"
Offset="0.6" />
<GradientStop Offset="0.8" />
<GradientStop Color="#00000000" />
<GradientStop Color="Black"
Offset="0.353" />
</LinearGradientBrush>
<SolidColorBrush x:Key="ブラシ_髪_光"
Color="#BFFFFFFF" />
</Window.Resources>
<Grid>
<UserControl ClipToBounds="True">
<Viewbox x:Name="LayoutRoot"
VerticalAlignment="Bottom">
<Grid Margin="0,0,0,-15">
<Grid x:Name="服"
Height="370.167"
Margin="340.576,0,134.094,4"
VerticalAlignment="Bottom">
<Path x:Name="シャツ"
Data="M732.66667,659.66633 L798.66635,709.66665 754.66625,939.00169 603.33362,938.33471 428.66839,747.00042 456.00125,658.99998 z"
Fill="{DynamicResource ブラシ_シャツ}"
Margin="0,88.167,138.333,0"
Stretch="Fill"
StrokeThickness="2" />
<Path Data="M270.5769,332.4365 C276.1962,346.63315 281.1917,357.60265 292.57187,368.66124"
HorizontalAlignment="Right"
Height="38.038"
Margin="0,0,216.761,0.506"
Stretch="Fill"
Stroke="{DynamicResource ブラシ_シャツ_輪郭}"
VerticalAlignment="Bottom"
Width="23.857" />
<Path Data="M281.67208,188.51151 C278.29371,217.76147 276.86802,253.27811 277.55461,265.02326 277.55418,265.8622 300.55292,335.08596 315.18427,362.31827"
HorizontalAlignment="Right"
Margin="0,0,195.178,7.868"
Stretch="Fill"
Width="37.762"
Stroke="{DynamicResource ブラシ_シャツ_輪郭}"
Height="173.825"
VerticalAlignment="Bottom" />
<Path Data="M263.54152,367.66024 C242.97063,340.41445 220.49695,283.57362 214.49059,277.56735 202.12179,261.54488 182.79561,247.31356 155.92983,235.02328"
Height="133.637"
Margin="155.93,0,245.791,1.507"
Stretch="Fill"
Stroke="{DynamicResource ブラシ_シャツ_輪郭}"
VerticalAlignment="Bottom" />
<Path Data="M264.04205,314.60509 L322.10297,318.10932 275.05405,342.63675 z"
HorizontalAlignment="Right"
Height="29.03"
Margin="0,0,187.23,26.532"
Stretch="Fill"
VerticalAlignment="Bottom"
Width="59.061"
Fill="{DynamicResource ブラシ_影}" />
<Path Data="M209.98585,348.13994 L198.97197,316.35541 143.2517,289.4124 z"
Fill="{DynamicResource ブラシ_影}"
HorizontalAlignment="Left"
Height="60.728"
Margin="141.249,0,0,26.532"
Stretch="Fill"
StrokeThickness="2"
VerticalAlignment="Bottom"
Width="68.736" />
<Path x:Name="左セーター"
Data="M582.68072,955.66116 L389.99969,777 C380.42141,761.32363 376.19115,746.69909 376.66636,733 L384.66603,663 320.26435,732.83334 304.93136,954.83334 z"
Fill="{DynamicResource ブラシ_セーター}"
Margin="-34.395,76.834,0,0.672"
Stretch="Fill"
StrokeThickness="2"
HorizontalAlignment="Left"
Width="277.749"
Stroke="{DynamicResource ブラシ_セーター_輪郭}" />
<Path Data="M-34.451103,148.76294 L33.985474,89.796702 C26.454151,112.18724 24.162009,187.04074 27.109048,215.3151 31.202159,203.05743 40.8619,164.32319 40.534451,171.67779 41.516798,174.29276 44.955011,183.11829 50.503289,191.78477 50.503289,191.78477 80.810021,219.89159 107.98855,244.73375 80.974384,244.89719 46.264806,239.66726 22.836618,248.71581 13.10519,288.81822 12.706933,328.19674 18.852226,367.06774 L-26.480147,366.57046 z"
HorizontalAlignment="Left"
Margin="-34.769,89.583,0,1.506"
Stretch="Fill"
Width="143.115"
Fill="{DynamicResource ブラシ_セーター_影}" />
<Path Data="M208.98481,367.66024 C136.46322,311.40206 69.416495,252.21878 12.780677,187.47318 8.2172328,166.87117 6.423651,147.52043 6.2737674,128.91221"
HorizontalAlignment="Left"
Margin="5.274,127.912,0,1.507"
Stretch="Fill"
Stroke="{DynamicResource ブラシ_セーター_輪郭}"
Width="204.711" />
<Path x:Name="右セーター"
Data="M937.9997,938.33324 C924.48984,791.66752 907.01328,693.20521 881.99969,686.33332 873.09746,679.59273 830.2305,670.3821 766.66667,659.66633 778.76108,693.41564 782.99027,729.76529 778.13354,769.11884 769.22817,828.05375 753.91624,884.98354 733.4452,938.33325 z"
Fill="{DynamicResource ブラシ_セーター}"
HorizontalAlignment="Right"
Margin="0,89.833,0,1.667"
Stretch="Fill"
StrokeThickness="2"
Width="204.167"
Stroke="{DynamicResource ブラシ_セーター_輪郭}" />
<Path Data="M771.93891,822.30877 C828.02809,840.38705 856.00086,850.47133 861.56474,859.37158 866.34188,832.94116 869.96501,810.51729 872.19554,793.48189 832.87486,762.79685 806.04656,740.11773 780.6071,713.5899 782.56971,720.50869 788.0429,747.90033 771.93891,822.30877 z"
Fill="{DynamicResource ブラシ_セーター_影}"
HorizontalAlignment="Right"
Margin="0,140.333,65.167,82.334"
Stretch="Fill"
StrokeThickness="2"
Width="102.166" />
<Path x:Name="左シャツ影"
Data="M53.877502,121.74884 L108.88135,190.47947 C108.88135,190.47947 233.01004,247.03637 237.01419,250.53989 241.01835,254.04342 243.52071,276.06502 243.52071,276.06502 219.17117,262.97273 194.08873,253.8177 167.44186,250.03852 139.93053,246.29373 133.44791,246.04129 110.36278,244.57037 86.786489,223.7326 56.57936,194.31432 51.422046,190.14646 43.794313,177.93616 38.440275,164.62486 36.932448,149.4511 z"
HorizontalAlignment="Left"
Margin="36.954,121.743,0,93.102"
Stretch="Fill"
Width="207.567"
Fill="{DynamicResource ブラシ_影}" />
<Path x:Name="右シャツ影"
Data="M400.01721,184.47048 C355.16522,195.17972 305.88189,233.79828 254.03239,288.57896 L252.03048,203.49044 308.08874,102.88632 C343.53918,116.49729 373.81199,144.73747 400.01721,184.47048 z"
Margin="252.03,102.886,109.316,80.588"
Stretch="Fill"
Fill="{DynamicResource ブラシ_影}" />
<Path Data="M806.5,671.333 C818.44288,691.81284 818.80662,736.29498 802.5,815.33301 792.90889,857.60542 781.90204,896.699 767.6531,936.67442"
HorizontalAlignment="Right"
Margin="0,100.5,121.862,2.334"
Stretch="Fill"
Stroke="{DynamicResource ブラシ_セーター_輪郭}"
Width="49.471" />
<Path Data="M900,936.33301 C888.56998,909.895 876.03031,884.78161 861,856.83301 852.966,830.551 847.58577,807.53158 844.5,787.33301"
HorizontalAlignment="Right"
Height="150"
Margin="0,0,37,2.667"
Stretch="Fill"
VerticalAlignment="Bottom"
Width="56.5"
Stroke="{DynamicResource ブラシ_シャツ_輪郭}">
<Path.OpacityMask>
<LinearGradientBrush EndPoint="0.5,1"
StartPoint="0.5,0">
<GradientStop Color="Black"
Offset="1" />
<GradientStop Color="#7FFFFFFF"
Offset="0.006" />
</LinearGradientBrush>
</Path.OpacityMask>
</Path>
<Path Data="M772.28457,616.52422 C795.43057,666.18778 814.10152,712.40186 834.5,760.83301 771.61561,703.71018 756.09841,687.49484 735.86607,686.9897 735.86607,686.9897 729.7962,616.0191 772.28457,616.52422 z"
Fill="{DynamicResource ブラシ_シャツ_影}"
HorizontalAlignment="Right"
Margin="0,46.247,103.5,179.075"
Stretch="Fill"
StrokeThickness="2"
Width="99.796"
Stroke="{DynamicResource ブラシ_シャツ_輪郭}" />
<Path Data="M664,570.833 C693.30755,576.64371 727.88334,590.27223 770.5,615.83301 762.34436,616.73883 756.6533,620.37843 753.5,626.83301 744.86293,680.84207 727.58235,726.46658 705.05625,770.48631"
Fill="{DynamicResource ブラシ_シャツ}"
Margin="235.333,0,166.5,168.514"
Stretch="Fill"
Stroke="{DynamicResource ブラシ_シャツ_輪郭}"
StrokeThickness="2" />
<Path Data="M678.66667,592.333 C698.33435,600.23874 711.62481,610.74742 720.66635,622.99967 723.24889,673.03057 717.25725,709.78892 704.66616,736.33154"
Fill="{DynamicResource ブラシ_シャツ_影}"
Height="146"
Margin="250,21.5,215.743,0"
Stretch="Fill"
StrokeThickness="2"
VerticalAlignment="Top" />
<Path Data="M458.5,684.583 C453.97658,715.12267 453.49206,746.95422 455.5,779.58301 466.62084,739.0618 482.88777,692.11691 490.75009,678.83301 L462.4997,667.08301"
Fill="{DynamicResource ブラシ_シャツ_影}"
HorizontalAlignment="Left"
Margin="25.706,96.25,0,159.417"
Stretch="Fill"
Stroke="{DynamicResource ブラシ_シャツ_輪郭}"
StrokeThickness="2"
Width="38.377" />
<Path Data="M504,580.833 C478.4902,607.08044 462.49694,641.82456 458,686.83301 461.8756,674.87335 463,671.58301 467.25,677.08301 473.5,686.08301 498.67178,756.47153 503,759.83301 504.26481,763.38057 556.82219,783.87268 577.46523,791.21628"
Margin="29.333,10,0,147.784"
Stretch="Fill"
Stroke="{DynamicResource ブラシ_シャツ_輪郭}"
StrokeThickness="2"
Fill="{DynamicResource ブラシ_シャツ}"
HorizontalAlignment="Left"
Width="121.465" />
<Path Data="M471.76391,635.94861 C482.69549,641.41205 492.23739,647.76207 499.66701,652.33301 514.95945,698.55129 533.6943,737.6471 556.33269,768.66634 L554.66638,593.99957 508.14736,579.77611 C498.79923,588.65244 483.76232,604.3747 471.76391,635.94861 z"
Fill="{DynamicResource ブラシ_シャツ_影}"
Margin="43.083,9,0,170.334"
Stretch="Fill"
StrokeThickness="2"
HorizontalAlignment="Left"
Width="86.583" />
<Path Data="M790.18834,714.23963 C803.12457,731.07524 796.04074,796.1349 780.67816,878.66184"
HorizontalAlignment="Right"
Margin="0,122.741,58.875,82.004"
Stretch="Fill"
Width="17.244"
Stroke="{DynamicResource ブラシ_セーター_輪郭}"
Opacity="0.5" />
<Path Data="M844.75,787.333 C844.75,785.583 830.75,731.08301 830.75,731.08301 L856,794.83301"
Fill="{DynamicResource ブラシ_セーター_影}"
HorizontalAlignment="Right"
Margin="0,159.5,83.75,146.917"
Stretch="Fill"
StrokeThickness="2"
Width="25.25" />
<Path Data="M867.54589,864.8216 C873.33807,831.12347 879.81384,794.16534 883.16545,785.58577 882.3703,823.19367 883.42291,874.24063 888.96412,910.90869 881.22895,893.44486 874.02786,877.86496 867.54589,864.8216 z"
Fill="{DynamicResource ブラシ_セーター_影}"
HorizontalAlignment="Right"
Height="127.586"
Margin="0,0,48.309,28.081"
Stretch="Fill"
StrokeThickness="2"
VerticalAlignment="Bottom"
Width="23.483" />
</Grid>
<Grid x:Name="髪_最背">
<Path x:Name="髪_最背_1"
Data="M724.5,484 C715.55473,545.86972 698.73081,592.05671 674.5,623.5 L674,526 C669.22589,575.69195 649.78006,607.22774 618,623.5 619.39428,602.35066 618.8369,583.07876 616,566 611.32958,588.16716 603,603.5 586,627 L563,602.5 535,643 468.5,608.5 481,642 C444.96972,630.29421 413.71566,613.70574 386,593.5 L345,519 326,393 363.5,194 452,150.5 598,156.5 673.5,298.5 z"
Stretch="Fill"
Stroke="{DynamicResource ブラシ_髪_輪郭}"
Height="493.5"
Margin="326.5,150.75,258,316.75"
StrokeThickness="2"
Fill="{DynamicResource ブラシ_髪_影}" />
<Path x:Name="髪_最背_2"
Data="M375.83333,525.16667 C387.07662,566.86855 406.03701,605.60639 428.25,642.25 411.30236,635.52325 394.61202,627.09638 378.25,616.5 351.81913,594.3796 333.58969,563.94089 323.25,525.5 327.804,559.09464 341.42412,590.23949 366.5,618.25 347.60319,610.25951 330.6767,599.15666 316,584.5 300.46584,567.46083 289.24825,547.95424 282.75,525.75 L277,484.5 275.5,391.16667 336.83333,387.49965 377.16667,507.16667"
Stretch="Fill"
Stroke="{DynamicResource ブラシ_髪_輪郭}"
Width="153.75"
Height="255.75"
HorizontalAlignment="Left"
Margin="277.125,388.5,0,0"
VerticalAlignment="Top"
StrokeThickness="2"
Fill="{DynamicResource ブラシ_髪_影}" />
</Grid>
<Grid x:Name="首"
Height="370.334"
Margin="424.24,0,362.763,45.982"
VerticalAlignment="Bottom">
<Path Data="M680.16667,529.66634 C681.58089,558.13638 681.5,595.66634 690,637.33301 695.33333,654.16634 697.7299,660.86442 707.49987,671.16641 L709.33322,741.33341 C707.01761,770.3461 697.66667,791.66686 687.33316,810.66681 679.99964,823.66689 683.24316,860.71859 696.66667,898.00063 L662.99935,844.00023 C659.43661,838.44215 654.54825,833.45695 647.66569,829.33356 L575.99692,790.66686 C561.74513,781.18125 548.60263,765.66859 537.32932,740.00015 L541.99674,667.0001 C536.82565,624.66678 526.70849,579.20924 514.32916,536.66666"
Stretch="Fill"
Stroke="{DynamicResource ブラシ_肌_輪郭}"
StrokeThickness="2"
Fill="{DynamicResource ブラシ_肌}" />
<Path Data="M85.798385,229.26329 C61.571461,226.3532 40.589318,223.62375 29.337097,219.78161 L33.15213,227.45521 z"
HorizontalAlignment="Left"
Height="10.532"
Margin="28.388,0,0,140.12"
Stretch="Fill"
StrokeThickness="2"
VerticalAlignment="Bottom"
Width="58.427"
Fill="{DynamicResource ブラシ_肌_影2}" />
<Path Data="M522.48631,558.80857 C531.34408,594.73575 539.68382,629.49553 544.29446,666.02417 560.31988,683.86026 575.9066,696.31825 590.3327,698.99967 608.87673,702.72301 625.53056,698.57668 639.99926,685.33273 665.58036,664.11629 682.37618,644.28072 684.35219,616.89224 681.21592,592.94285 679.74187,568.02326 678.67154,544.16421"
Height="158.156"
Margin="8.167,14.5,25,0"
Stretch="Fill"
StrokeThickness="2"
VerticalAlignment="Top"
Fill="{DynamicResource ブラシ_肌_影2}" />
<Path Data="M32.224039,227.36959 C48.838299,227.88095 66.555438,228.66172 86.030008,229.87177 94.714548,232.12481 102.69728,235.76198 110.05494,240.63401"
Height="13.263"
Margin="32.224,0,87.945,129.701"
Stretch="Fill"
StrokeThickness="2"
VerticalAlignment="Bottom"
Stroke="{DynamicResource ブラシ_肌_輪郭}" />
<Path Data="M198.90589,212.6598 C190.21973,218.50336 182.5033,225.32872 176.3372,233.72369"
HorizontalAlignment="Right"
Height="23.064"
Margin="0,0,0.094,135.61"
Stretch="Fill"
Stroke="{DynamicResource ブラシ_肌_輪郭}"
StrokeThickness="2"
VerticalAlignment="Bottom"
Width="24.569" />
<Path Data="M621.30154,755.34269 L619.68661,688.07739 C610.22771,677.23609 605.8879,665.28115 601.69175,649.39396 601.69175,685.74909 614.63151,719.23324 621.30154,755.34269 z"
Fill="{DynamicResource ブラシ_肌_影2}"
HorizontalAlignment="Right"
Margin="0,103.829,1.846,158.677"
Stretch="Fill"
StrokeThickness="2"
Width="21.315" />
<Path Data="M176.58799,99.064471 C181.01733,112.48097 195.39694,129.48948 197.90426,141.77649 187.62303,130.74249 180.85098,122.13429 178.34331,112.35448 178.09255,110.84991 176.58799,99.064471 176.58799,99.064471 z"
Fill="{DynamicResource ブラシ_肌_輪郭}"
HorizontalAlignment="Right"
Height="42.713"
Margin="0,99.733,1.846,0"
Stretch="Fill"
StrokeThickness="2"
VerticalAlignment="Top"
Width="21.315" />
<Path Data="M24.458474,114.69508 C27.486118,147.31694 26.252297,178.85321 22.118493,209.65073 24.927942,220.20947 31.13061,227.87882 39.169794,238.07031 33.728307,228.09253 29.081504,220.82694 27.802273,210.98796 28.423105,184.72006 28.812888,159.7125 29.892392,141.69428 z"
Fill="{DynamicResource ブラシ_肌_輪郭}"
HorizontalAlignment="Left"
Margin="22.118,114.695,0,132.264"
Stretch="Fill"
StrokeThickness="2"
Width="17.052" />
<Path Data="M52.933271,252.33441 C67.444107,255.12098 79.845033,258.42194 89.826002,262.31285 96.759213,269.04111 102.12601,275.96946 106.37779,283.04024 82.68537,271.09071 61.738626,261.33036 52.933271,252.33441 z"
Height="32.098"
Margin="52.586,0,92.623,86.332"
Stretch="Fill"
VerticalAlignment="Bottom"
Fill="{DynamicResource ブラシ_肌_影2}" />
<Path Data="M5.9776962,36.623944 L75.689904,88.281417 C86.054992,96.139764 107.78781,94.802724 117.31681,85.273013 L168.97379,31.107175"
Height="62.29"
Margin="6.571,26.594,30.434,0"
Stretch="Fill"
StrokeThickness="2"
VerticalAlignment="Top"
Fill="{DynamicResource ブラシ_肌_輪郭}" />
<Path Data="M21.61703,89.033862 L31.82791,149.30795"
HorizontalAlignment="Left"
Height="62.435"
Margin="20.617,88.034,0,0"
Stretch="Fill"
Stroke="{DynamicResource ブラシ_肌_輪郭}"
VerticalAlignment="Top"
Width="12.283"
Opacity="0.5" />
</Grid>
<Grid x:Name="耳"
HorizontalAlignment="Right"
Height="88.648"
Margin="0,378.971,293.802,0"
VerticalAlignment="Top"
Width="53.618">
<Path Data="M645.33333,396.66667 C648.35681,383.92969 655.77974,375.26749 668.66698,371.66632 674.60202,370.72859 679.51461,371.50075 682.33314,374.99937 688.14868,383.37605 691.07971,395.96539 689.28909,414.71318 688.14953,432.87487 678.21148,450.00922 671.53211,455.94728 663.66139,462.8011 651.28021,466.94659 642.04604,464.35875 z"
Margin="3.75,0,0,0"
Stretch="Fill"
Fill="{DynamicResource ブラシ_肌_影2}"
Stroke="{DynamicResource ブラシ_肌_輪郭}" />
<Path Data="M647.33407,398.25573 C647.34023,410.47205 647.34004,423.16118 647.33438,436.25573"
Fill="{DynamicResource ブラシ_肌}"
Margin="13.116,26.452,25.324,30.37"
Stretch="Fill" />
<Path Data="M683.11037,435.61862 C679.79016,434.21541 675.98508,433.63996 671.58302,434.08368 668.58928,434.88321 664.45856,436.63096 659.58364,438.99936 L636.58481,452.32911 640.5031,465.01805 C648.50223,466.71373 656.89574,464.71466 664.41867,460.49559 673.72371,455.64943 679.12634,445.56034 683.11037,435.61862 z"
Height="29.938"
Margin="0,0,6.118,0.997"
Stretch="Fill"
VerticalAlignment="Bottom"
Fill="{DynamicResource ブラシ_肌}"
StrokeThickness="0" />
<Path Data="M677.97259,408.35092 C677.97259,408.35092 673.86989,425.23155 672.97581,428.70561 672.31927,431.51755 670.99477,433.18527 668.83313,434.49967 L648.16371,447.20322"
Margin="11.581,36.911,12.201,20.154"
Stretch="Fill"
Stroke="{DynamicResource ブラシ_肌_輪郭}"
Opacity="0.5" />
</Grid>
<Grid x:Name="イヤリング"
HorizontalAlignment="Right"
Margin="0,445,296,458"
Width="43.687">
<Rectangle Height="15"
Margin="10.161,0,18.526,0"
VerticalAlignment="Top"
Fill="{DynamicResource ブラシ_イヤリング_耳あて}"
RenderTransformOrigin="0.5,0.5"
Stroke="{DynamicResource ブラシ_イヤリング_耳あて_輪郭}">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform />
<RotateTransform Angle="41.988" />
<TranslateTransform />
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
<Path Data="M2.2645893,2 L41.686588,2 L41.686588,43.098 L2.2645893,43.098 z M2,21.808844 L41.330925,22.361937 M22.445848,2.2648361 L21.777081,43.726895"
Margin="0,14.009,0,0"
RenderTransformOrigin="0.503028256766017,0.49312336440942"
Stretch="Fill"
StrokeThickness="4"
Stroke="{DynamicResource ブラシ_イヤリング}">
<Path.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform />
<RotateTransform Angle="37.277" />
<TranslateTransform />
</TransformGroup>
</Path.RenderTransform>
</Path>
</Grid>
<Grid x:Name="輪郭">
<Path x:Name="輪郭_1"
Canvas.Top="0"
Data="M151.66687,0.50000376 C137.97594,7.3185855 124.03686,18.295386 109.96162,32.138489 L46.666957,34.750002 0.49999214,143.50021 4.8336667,233.16664 C10.601686,251.37862 16.071287,268.16538 21.166998,283.16651 27.152477,302.23111 34.540721,321.03943 43.834027,339.49969 49.363058,350.19751 55.344446,360.33189 61.834343,369.83294 67.533343,378.30754 74.877876,384.85005 83.834644,389.49955 L99.535248,398.2033 C127.15091,411.08885 149.68836,421.57514 170.8339,427.66667 180.50744,430.60296 189.4838,432.7499 197.66757,433.99944 209.42093,436.32451 219.98998,434.82064 227.83375,427.99974 233.91347,423.36127 239.66793,418.63265 245.16734,413.83334 L271.00072,388.16667 C289.66741,369.16667 293.36916,363.31079 305.33377,347.16667 321.66698,326.16667 322.16755,308.5002 323.16712,293.66667 323.11035,279.83206 325.11004,265.49865 324.83377,251.66667 325.39707,216.51978 323.91281,202.12148 321.47072,190.75001 L309.47073,144.25 286.58376,59.250007 C283.4806,46.96565 278.79181,37.084556 271.83377,29.500006 259.03649,18.822895 241.917,9.2500704 219.08381,4.2500037"
Margin="327.75,182.5,0,0"
Stretch="Uniform"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Height="435.52"
Width="325.453"
StrokeThickness="2"
Fill="{DynamicResource ブラシ_肌}"
Stroke="{DynamicResource ブラシ_肌_輪郭}" />
<Path x:Name="輪郭_影"
Data="M151.85945,0 C174.01421,-1.244573 195.43902,-0.23183075 215.81405,4.0272283 238.84641,9.0541036 258.99219,18.40103 271.90109,29.135389 278.9198,36.760609 283.6495,46.694683 286.77972,59.04491 L309.86633,144.50067 323.17557,193.55757 C295.1467,127.48889 278.8709,6.1961494 181.09428,9.7278337 145.39459,9.7278347 115.82236,43.371544 86.06269,134.20905 64.716163,199.60208 51.275222,265.18334 43.497336,337.20666 34.161452,318.69402 27.550022,302.01895 21.537119,282.90023 16.418065,267.85653 11.008644,251.44566 5.2141992,233.18199 L0,143.40605 46.378482,34.347206 109.96313,31.728279 C124.10285,17.845888 138.1058,6.8379335 151.85945,0 z"
Fill="{DynamicResource ブラシ_肌_影}"
HorizontalAlignment="Left"
Height="337.703"
Margin="329.084,182.004,0,0"
Stretch="Fill"
VerticalAlignment="Top"
Width="320.415"
StrokeThickness="0" />
</Grid>
<Grid x:Name="左眼">
<Path Data="M433.33333,387.16667 C437.16643,393.22982 439.46735,400.8179 440.16701,409.99966 440.96659,417.30234 439.94089,423.30151 438.00046,430.66617 433.00062,437.83292 420.0973,441.48463 410.33549,443.16631 399.89625,445.00497 389.90939,445.40923 380.33687,444.49966 372.6711,443.00004 365.17157,435.16656 360.33851,427.833 L351.67276,413.83299 C354.40025,405.18361 359.57472,398.20683 367.33808,392.99966 379.01655,386.19356 390.00334,382.66526 397.83618,381.99893 397.83618,381.99893 410.33529,381.33265 410.83526,381.49931 418.50154,381.66524 427.50097,385.16532 433.33333,387.16667 z"
HorizontalAlignment="Left"
Height="63.493"
Margin="351.667,381.474,0,0"
Stretch="Fill"
VerticalAlignment="Top"
Width="88.773"
Fill="{DynamicResource ブラシ_ハイライト}" />
<Path Data="M423.26606,382.46189 C426.69842,384.69557 430.13223,395.86011 432.64116,404.6609 434.90151,413.49843 437.65774,429.0928 436.33752,433.55887 435.44457,437.23481 423.26539,440.65219 416.6317,442.36181 L407.1565,444.46149 C400.57806,446.08197 393.29191,446.56282 390.38699,441.96583 384.9331,433.03319 383.25582,426.04901 380.43888,417.04607 379.00163,412.46154 377.2695,407.69006 376.03741,401.51157 373.92446,391.27293 380.41655,385.31534 386.67515,382.47866 393.81966,379.44184 396.46052,379.70344 403.98698,378.91575 412.70182,378.78439 416.39909,380.22968 423.26606,382.46189 z"
Fill="{DynamicResource ブラシ_虹彩}"
HorizontalAlignment="Left"
Height="65.975"
Margin="375.781,378.992,0,0"
Stretch="Fill"
VerticalAlignment="Top"
Width="60.794"
Stroke="{DynamicResource ブラシ_虹彩_輪郭}"
StrokeThickness="3" />
<Ellipse Fill="{DynamicResource ブラシ_ハイライト}"
HorizontalAlignment="Left"
Height="42.022"
Margin="391.743,395.847,0,0"
VerticalAlignment="Top"
Width="35.718"
RenderTransformOrigin="0.5,0.5">
<Ellipse.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform />
<RotateTransform Angle="-6.5" />
<TranslateTransform />
</TransformGroup>
</Ellipse.RenderTransform>
</Ellipse>
<Ellipse Fill="{DynamicResource ブラシ_瞳孔}"
HorizontalAlignment="Left"
Height="40.626"
Margin="392.183,391.713,0,0"
VerticalAlignment="Top"
Width="32.776"
RenderTransformOrigin="0.5,0.5">
<Ellipse.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform />
<RotateTransform Angle="-6.5" />
<TranslateTransform />
</TransformGroup>
</Ellipse.RenderTransform>
</Ellipse>
<Path Data="M359.28741,425.8327 C368.93812,417.51877 377.16684,411.83334 394.33334,406.00002 408.3988,402.16873 423.17918,398.85872 437.9996,397.79158 435.79129,391.66662 434.87464,386.83332 430.16634,385.83347 418.11302,381.22276 406.6131,379.61147 395.66667,381.00014 L367.33361,393.16678 C361.23152,396.17015 356.04726,401.04076 352.78749,410.83309 352.90223,416.14387 354.65977,422.32955 359.28741,425.8327 z"
Fill="{DynamicResource ブラシ_瞳_影}"
HorizontalAlignment="Left"
Height="45.315"
Margin="352.787,380.518,0,0"
Stretch="Fill"
VerticalAlignment="Top"
Width="85.213" />
<Path Data="M439.65381,389.8162 C431.0957,385.72816 421.68694,380.47859 411.5,379.25 404.35251,378.62935 397.51975,379.08963 391,380.625 380.83171,382.87461 371.08409,386.04839 362.5,392.125 354.35364,396.94228 347.8842,410.33438 348.75,412.75 348.25551,415.49464 360.72053,428.92434 367.75,436.75 L358,422.125 C356.06609,418.6523 355.30921,415.15424 356,411.625 358.83076,405.63517 361.99344,401.16443 365.64462,398.33473 370.42473,394.73074 378.04171,389.78195 389.5,385.125 396.84634,383.50952 404.17981,382.87477 411.5,383.25 418.48502,383.76084 428.81831,386.8578 439.65381,389.8162 z"
HorizontalAlignment="Left"
Height="58.772"
Margin="348.672,378.978,0,0"
Stretch="Fill"
VerticalAlignment="Top"
Width="91.995"
Fill="{DynamicResource ブラシ_瞼}" />
<Ellipse HorizontalAlignment="Left"
Height="18.409"
Margin="409.493,391.394,0,0"
VerticalAlignment="Top"
Width="23.089"
Fill="{DynamicResource ブラシ_ハイライト}"
RenderTransformOrigin="0.5,0.5">
<Ellipse.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform />
<RotateTransform Angle="-13.273" />
<TranslateTransform />
</TransformGroup>
</Ellipse.RenderTransform>
</Ellipse>
<Ellipse Fill="{DynamicResource ブラシ_ハイライト}"
HorizontalAlignment="Left"
Height="10.334"
Margin="386,433.5,0,0"
VerticalAlignment="Top"
Width="9.667" />
</Grid>
<Grid x:Name="右眼">
<Path Data="M549.5,377.25 C551.57725,389.90895 556.5,412.12481 559.875,413.7494 568.5,418.12473 585.30738,417.60823 600.5,414.99977 609.5,411.62481 618.5,406.49983 624.5,399.5 627,392.37487 629.25499,385.91648 630.25,379.25 631.39146,372.8014 630.91674,367.30574 628,363.25 621.4886,357.27654 614.27047,353.35086 606.25,351.75 598.24268,350.26205 589.78658,350.28128 580.75,352.25 568.16894,355.65268 557.96255,364.46507
549.5,377.25 z"
Fill="{DynamicResource ブラシ_ハイライト}"
HorizontalAlignment="Right"
Height="66.305"
Margin="0,350.696,353.178,0"
Stretch="Fill"
StrokeThickness="0"
VerticalAlignment="Top"
Width="81.322" />
<Path Data="M593.70524,349.34149 C599.44593,352.05558 601.77386,357.43504 604.55016,363.20407 606.02506,366.82047 607.08879,370.72388 607.83333,374.99967 609.29498,382.89797 610.75551,393.95591 610.36303,401.60436 610.25191,403.76973 609.78015,405.04293 608.97442,406.75622 607.09657,409.38102 603.50032,410.58323 599.917,411.74964 595.50036,413.16665 582.65667,414.08518 574.00046,413.74963 570.72301,413.54358 567.9874,412.26258 565.83371,409.83297 562.50052,405.99988 560.95973,388.64119
559.08376,377.16643 558.54729,371.64016 559.35,364.55138 562.47233,360.70728 567.25922,356.317 572.67769,353.12757 578.8694,351.40833 582.84415,349.78094 589.58128,348.96146 593.70524,349.34149 z"
HorizontalAlignment="Right"
Height="67.755"
Margin="0,349.328,372.604,0"
Stretch="Fill"
VerticalAlignment="Top"
Width="52.465"
StrokeThickness="3"
Fill="{DynamicResource ブラシ_虹彩}"
Stroke="{DynamicResource ブラシ_虹彩_輪郭}" />
<Ellipse Fill="{DynamicResource ブラシ_ハイライト}"
HorizontalAlignment="Right"
Height="41.979"
Margin="0,366.282,381.649,0"
StrokeThickness="0"
VerticalAlignment="Top"
Width="32.153"
RenderTransformOrigin="0.5,0.5">
<Ellipse.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform />
<RotateTransform Angle="-3.1" />
<TranslateTransform />
</TransformGroup>
</Ellipse.RenderTransform>
</Ellipse>
<Ellipse Fill="{DynamicResource ブラシ_瞳孔}"
HorizontalAlignment="Right"
Height="40.761"
Margin="0,363.73,383.075,0"
StrokeThickness="0"
VerticalAlignment="Top"
Width="30.095"
RenderTransformOrigin="0.5,0.5">
<Ellipse.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform />
<RotateTransform Angle="-3.1" />
<TranslateTransform />
</TransformGroup>
</Ellipse.RenderTransform>
</Ellipse>
<Path Data="M550.30144,375.45161 L552.38135,385.75948 C564.74896,379.21524 577.6519,372.75445 590.3286,372.00035 602.78174,372.46434 615.5076,375.00174 628.49146,379.50034 L631.18726,367.99394 603.66083,350.33367 579.33015,351.834 C568.98949,358.32012 559.51181,365.93172 550.30144,375.45161 z"
Fill="{DynamicResource ブラシ_瞳_影}"
HorizontalAlignment="Right"
Height="38.448"
Margin="0,349.333,350.833,0"
Stretch="Fill"
StrokeThickness="0"
VerticalAlignment="Top"
Width="83.854" />
<Path Data="M626.50062,391.00007 L633.20233,368.98272 C633.6094,366.91194 632.16921,365.5772 630.95268,364.06608 626.83395,359.25034 620.50059,354.50038 615.29076,352.34084 606.27795,348.92885 596.33383,348.50033 585.25045,349.66709 577.91709,350.66698 570.50759,354.18993 563.75031,359.12534 557.063,364.29129 553.6052,368.54378 549.08395,375.9169 555.03451,369.5558 558.87779,366.36453 564.50031,362.12534 571.60134,357.04264 577.19213,353.87217 584.91712,352.00058 591.66714,350.9172 599.22634,351.70235
605.50031,353.00034 613.8339,354.75038 625.75031,363.58357 627.75031,367.6252 629.16697,370.66685 627.77407,381.53737 626.50062,391.00007 z"
HorizontalAlignment="Right"
Height="42.918"
Margin="0,349.082,349.728,0"
Stretch="Fill"
VerticalAlignment="Top"
Width="85.189"
Fill="{DynamicResource ブラシ_瞼}"
Stroke="{DynamicResource ブラシ_瞼}" />
<Ellipse Fill="{DynamicResource ブラシ_ハイライト}"
HorizontalAlignment="Right"
Height="17.526"
Margin="0,362.233,372.36,0"
StrokeThickness="0"
VerticalAlignment="Top"
Width="22.398"
RenderTransformOrigin="0.5,0.5">
<Ellipse.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform />
<RotateTransform Angle="-16.983" />
<TranslateTransform />
</TransformGroup>
</Ellipse.RenderTransform>
</Ellipse>
<Ellipse Fill="{DynamicResource ブラシ_ハイライト}"
HorizontalAlignment="Right"
Height="9.656"
Margin="0,405.833,409.449,0"
StrokeThickness="0"
VerticalAlignment="Top"
Width="10.384" />
</Grid>
<Grid x:Name="口"
HorizontalAlignment="Left"
Height="100"
VerticalAlignment="Top"
Width="100">
<Path Data="M505.75,549.75 C504.49686,545.25936 513.38455,540.96783 522.81955,539.42572 535.96039,537.18336 544.35665,537.17634 545,541.5 544.86993,548.31313 541.1974,552.67355 531.5,554.75 522.55251,556.66587 508.65526,555.60531 505.75,549.75 z"
HorizontalAlignment="Right"
Height="17.666"
Margin="0,0,-445.002,-455.64"
Stretch="Fill"
VerticalAlignment="Bottom"
Width="39.369"
Fill="{DynamicResource ブラシ_口}"
StrokeThickness="1.5"
Stroke="{DynamicResource ブラシ_口_輪郭}" />
</Grid>
<Grid x:Name="鼻"
HorizontalAlignment="Left"
Height="100"
VerticalAlignment="Top"
Width="100">
<Path Data="M523.6954,492.71569 C525.17975,491.86188 526.0048,486.68552 525.51011,485.26355 524.79523,483.84144 523.28073,483.21525 521.60585,483.61415 521.44104,484.69465 520.2307,488.82931 520.34069,491.74852 520.93224,493.00348 522.6385,493.18842 523.6954,492.71569 z"
HorizontalAlignment="Right"
Height="10.392"
Margin="0,0,-426.914,-393.7"
Stretch="Fill"
VerticalAlignment="Bottom"
Width="6.047"
Fill="{DynamicResource ブラシ_肌_影}" />
<Path Data="M521.50293,481.37105 C522.02011,483.88495 521.75286,484.93357 521.19049,487.12107"
HorizontalAlignment="Right"
Height="6.75"
Margin="0,0,-422.78,-388.122"
Stretch="Fill"
Stroke="{DynamicResource ブラシ_肌_輪郭}"
VerticalAlignment="Bottom"
Width="1.589" />
</Grid>
<Grid x:Name="髪">
<Path x:Name="髪_メイン"
Data="M501.33333,176.66667 C499.40701,173.00049 497.25009,170.74997 491.16701,169.83301 485.39056,169.96018 480.20391,171.6497 475.83287,175.49973 468.51402,182.10282 462.66003,189.39319 457.8329,197.16533 443.508,218.35042 429.94316,243.81371 416.83279,273.16033 405.92796,300.06145 397.08752,327.91057 389.83295,356.48796 381.61269,390.49258 375.45665,421.96502 371.16655,451.14854 368.63645,465.77044 366.57034,480.68689 364.83283,495.81193 361.16695,476.66607 359.66441,458.59351
360.16647,441.48243 360.93835,410.54397 362.73796,381.58816 365.49951,354.48806 367.9919,332.03098 370.65471,312.41219 373.49956,295.82519 L380.83293,251.16141 C373.08024,283.13051 365.9711,314.97195 360.49948,346.48858 356.95976,363.63467 353.87764,378.29081 351.99916,391.98565 347.79956,417.24687 345.2558,440.14416 343.16603,460.14789 341.45915,482.591 341.2277,505.034 342.83235,527.47687 343.92845,541.71009 345.57983,555.39119 347.8327,568.47422 350.5097,587.01282 355.90068,602.11001 368.49932,619.63749 337.49913,592.8056 321.1657,563.47418 312.49915,538.14288 299.29447,504.47593 290.90368,468.00252
287.16565,428.81661 L285.49864,407.98462 C285.72921,413.19221 285.68053,437.08774 285.30474,461.81159 285.19892,468.77332 285.06717,475.80072 284.90842,482.49508 284.7111,490.81587 284.47206,498.62211 284.18925,505.14814 283.63334,517.97609 282.90832,525.85749 281.9986,522.9771 278.63778,545.97476 280.86735,573.8003 288.99865,595.47239 280.49666,581.14435 272.09628,565.81448 263.83205,549.14207 252.23924,522.9479 247.94224,491.69245 245.49832,459.98118 243.75255,435.23468 243.26638,411.41305
243.99831,388.48582 242.79441,330.86268 246.74316,275.01529 255.9984,220.99669 264.28026,186.93339 277.1142,158.10251 294.49871,134.5023 314.43557,110.64882 336.73826,89.94251 361.49924,72.506327 394.65527,53.314408 429.40021,43.618364 466.00006,45.008109 496.33688,44.503636 527.30789,48.942162 559.0008,59.007202 589.9042,71.724745 613.52964,87.72614 631.00136,106.50412 659.84924,140.17498 680.17318,177.31201 693.00183,217.49692 706.43295,257.14258
716.1247,295.42165 722.50206,332.48946 733.80317,378.93477 739.57553,424.61312 739.50221,469.48057 741.01714,492.01435 740.7896,513.1301 739.00219,532.97645 735.31997,560.57999 729.41398,581.90276 722.00206,598.97217 725.58817,578.34331 727.60783,557.18718 726.00147,533.97638 726.08809,516.94101 724.47923,500.36305 722.50206,484.97956 L696.00129,523.9773 C704.10335,487.49539 704.59558,450.72875 693.0429,412.94075 691.13826,400.50949 685.29529,387.51081 679.02833,375.30284 668.33058,345.32857 620.94486,270.8719 614.25813,248.79103 612.38495,242.52236 611.01128,236.37906 608.88834,230.73726 603.92528,216.95283 600.32509,206.74727 593.02876,195.1312 583.55614,182.97664 573.25055,170.99995 556.50045,166.50024 544.27789,164.57712 532.27087,165.97005 520.50023,170.99995 517.9766,172.48792 515.65677,174.4349
513.50019,176.74958"
Margin="243.671,44.869,242.496,340.333"
Stretch="Fill"
Stroke="{DynamicResource ブラシ_髪_輪郭}"
StrokeThickness="2"
Fill="{DynamicResource ブラシ_髪}" />
<Path x:Name="髪_右影"
Data="M633.833,207.50033 C645.75263,242.0464 657.43135,276.81932 668.49969,312.16699 681.78076,356.16613 694.55647,400.66995 705.684,446.81972 707.66682,425.34418 707.81756,403.0043 705.4997,379.49976 702.01513,339.59627 696.4005,302.84854 689.16636,268.50013 698.25657,301.79793 705.86422,335.12384 710.83303,368.4998 716.8705,405.53235 721.50145,449.74609 723.23468,489.94706 L690.21942,553.37393 693.2008,486.24285 C702.08532,480.50113 689.40657,416.07176 689.40657,416.07176 691.42741,397.07745 685.11744,386.3776 680.29216,376.54867 678.21367,368.79783 679.67374,372.68225 677.57021,365.22674 671.65997,344.27913 667.10902,320.30364 661.16655,299.83348 z"
HorizontalAlignment="Right"
Margin="0,207.5,259.75,406.644"
Stretch="Fill"
Width="90.417"
Fill="{DynamicResource ブラシ_髪_影}" />
<Path x:Name="髪_右ライン"
Data="M642.5,154.5 C660.95758,186.22385 676.27599,222.84175 688.5,264.5 699.05005,302.25189 702.97286,333.48462 706,368 709.32172,397.33129 709.33546,426.66473 706.5,456 706.5,456 702,507.5 702,507.5"
HorizontalAlignment="Right"
Margin="0,154.5,275.469,453.5"
Stretch="Fill"
Width="66.031"
Stroke="{DynamicResource ブラシ_髪_輪郭}" />
<Path x:Name="髪_左影"
Data="M14.799812,131.16701 L33.666992,357.25 27.416985,358.25 25.666527,355.33334 C21.83326,374.33334 22.833244,397.5 30.662979,425.74997 24.014442,408.28854 18.58947,390.2854 14.970276,371.48282 4.9911346,331.89441 0.12762451,289.22906 0,243.71524 1.1318207,205.7314 6.1143494,168.22139 14.799812,131.16701 z M148.667,0 C139.82267,26.956161 131.98963,53.594177 125.292,79.875 122.417,89.75 109.167,150.25 102.542,184 105.97895,151.45261 109.90049,122.9024 114.167,106 124.82911,66.899673 136.44996,32.10965 148.667,0 z"
HorizontalAlignment="Left"
Margin="256.833,166.5,0,368.75"
Stretch="Fill"
Width="148.667"
Fill="{DynamicResource ブラシ_髪_影}" />
<Path x:Name="髪_左ライン"
Data="M362.5,112.75 C335.69354,128.44487 318.94285,151.05635 305.25,180.25 290.0482,210.01055 280.01464,245.743 273.5,286.5 267.54957,322.66673 265.52484,358.1709 267.5,393 267.74229,443.83163 278.28209,491.16655 299,535 288.76642,484.55546 284.67048,451.97447 286.37174,436.26617"
HorizontalAlignment="Left"
Margin="266.767,112.75,0,426"
Stretch="Fill"
Width="95.733"
Fill="{DynamicResource ブラシ_髪}">
<Path.Stroke>
<LinearGradientBrush EndPoint="0.5,1"
StartPoint="0.5,0">
<GradientStop Color="{DynamicResource 色_髪_輪郭}"
Offset="0.7" />
<GradientStop Offset="1"
Color="#00000000" />
</LinearGradientBrush>
</Path.Stroke>
</Path>
<Path x:Name="髪_左ライン影"
Data="M293.5,480.25 C290.56092,467.02821 288.61231,454.17137 287.90318,441.77122 286.02858,430.84979 285.40783,371.22465 287.75,352 282.06834,383.55149 279.32092,416.45668 281.75,451.75 283.10525,472.09255 289.81543,502.89212 299.5,539.5 L298,507 z"
HorizontalAlignment="Left"
Margin="280.814,352,0,420.5"
Stretch="Fill"
Width="19.686"
Fill="{DynamicResource ブラシ_髪_影}" />
<Path Data="M367.03534,145.51695 C352.65291,188.26427 353.93103,220.94203 375.12703,233.24288 386.72256,240.84373 460.4041,249.99799 505.01286,250.85263 L500.53564,262.5139 C426.67565,261.39092 364.33527,255.79149 346,238.833 L338.87187,250.43082 C343.46866,204.94959 350.15739,179.039 367.03534,145.51695 z"
Height="118.01"
Margin="251.265,163.032,0,0"
Stretch="Fill"
VerticalAlignment="Top"
Fill="{DynamicResource ブラシ_髪_光}"
HorizontalAlignment="Left"
Width="167.16" />
<Path Data="M700.96699,225.26342 C730.23574,215.63456 752.0297,191.35981 760.98309,153.87923 752.09868,136.1107 737.29472,111.68563 723.70318,96.036306 751.70318,143.78631 743.8707,199.8863 696.6207,210.8863 698.23822,215.59771 700.06405,220.62976 700.96699,225.26342 z"
Fill="{DynamicResource ブラシ_髪_光}"
HorizontalAlignment="Right"
Height="129.227"
Margin="0,116.39,310.278,0"
Stretch="Fill"
VerticalAlignment="Top"
Width="64.362" />
</Grid>
<Grid x:Name="左眼plus">
<Path Data="M416.79662,360.94823 C421.86874,359.85176 440.19871,360.17574 443.29412,361.3388 449.06616,362.59681 456.9924,372.99376 456.09848,375.89595 455.81405,377.3214 445.7733,377.27279 441.70819,376.01352 434.42348,369.28189 427.60333,364.40755 416.79662,360.94823 z"
HorizontalAlignment="Left"
Height="17.672"
Margin="416.798,360.332,0,0"
Stretch="Fill"
VerticalAlignment="Top"
Width="40.356"
Fill="{DynamicResource ブラシ_肌_影}" />
<Path Data="M0.49999999,3.2519753 C0.49999999,3.2519753 11.79201,1.0438327 14.833994,0.91847993 17.83429,0.48046553 29.16701,0.25211127 36.667002,0.91847993 M41.16701,17.273992 C33.042019,10.10701 24.10451,3.5439855 13.66701,0.93999431"
HorizontalAlignment="Left"
Height="17.774"
Margin="401.333,359.581,0,0"
Stretch="Fill"
VerticalAlignment="Top"
Width="41.667"
Stroke="{DynamicResource ブラシ_肌_輪郭}"
Opacity="0.6" />
<Path Data="M426,333.5 C436.13892,336.66729 463.75,345.87527 463.375,348.5 462.24979,350.00034 450.65959,348.38175 442.25,346.875 426.75017,345.25051 397.25006,334.75011 397.375,332 z"
HorizontalAlignment="Left"
Height="17.097"
Margin="397.375,332.125,0,0"
Stretch="Fill"
VerticalAlignment="Top"
Width="66.004"
Fill="{DynamicResource ブラシ_肌_影}" />
<Path Data="M324.75,349.5 C338.85792,341.92188 355.437,335.93994 368.3914,334.12121 387.04423,331.94883 405.72624,330.93928 421.75,332 427.38705,332.28163 432.23598,333.83971 436.25,336.75 431.36014,335.15384 426.437,334.22928 421.99717,334.12115 407.13972,333.46333 388.85367,333.14448 368.64367,335.18176 358.687,336.06511 338.87908,342.81774 324.75,349.5 z"
HorizontalAlignment="Left"
Height="17.9"
Margin="322.688,331.1,0,0"
Stretch="Fill"
VerticalAlignment="Top"
Width="111.5"
Fill="{DynamicResource ブラシ_肌_輪郭}" />
</Grid>
<Grid x:Name="右眼plus">
<Path Data="M559.5,339.33333 C552.5841,341.93136 546.10282,344.96445 540.66486,349.24771 535.82171,354.27494 530.88507,363.15155 531.16714,366.50032 531.47334,368.42949 532.56091,369.24077 534.5001,368.83367 536.97973,367.80313 538.97607,366.3078 540.86612,364.60238 543.36137,361.82161 547.48844,356.02852 550.24341,350.61794 z"
HorizontalAlignment="Right"
Height="30.606"
Margin="0,339.333,423.5,0"
Stretch="Fill"
VerticalAlignment="Top"
Width="29.345"
Fill="{DynamicResource ブラシ_肌_影}" />
<Path Data="M37.333036,0.50000002 C29.512816,0.86660807 22.593389,2.2440019 16.726453,4.8024048 11.078602,7.2038051 5.689675,9.7230499 0.5,12.332981 M6.2520423,18.099801 C9.3019207,13.209928 13.044506,8.6646709 17.41903,4.4337984"
HorizontalAlignment="Right"
Height="18.599"
Margin="0,334.167,402.167,0"
Stretch="Fill"
VerticalAlignment="Top"
Width="37.833"
Stroke="{DynamicResource ブラシ_肌_輪郭}"
Opacity="0.6" />
<Path Data="M519.16635,328.0004 C517.99888,326.16637 528.43658,317.08936 533.74933,312.24757 L565.66678,295.16307 C557.97364,300.98192 551.27403,307.57816 544.99961,315.24656 539.47847,322.04386 532.91579,338.0805 530.16592,337.66348 528.33237,338.16361 518.66598,330.08331 519.16635,328.0004 z"
HorizontalAlignment="Right"
Height="42.522"
Margin="0,294.417,418.333,0"
Stretch="Fill"
VerticalAlignment="Top"
Width="46.59"
Fill="{DynamicResource ブラシ_肌_影}" />
<Path Data="M608.05486,282.02202 C596.60932,284.11531 585.31141,287.08215 573.75,290.75 562,295 549.96393,301.53284 538.9375,307.125 535.33474,309.38549 531.74419,311.93258 528.33366,315.01564 525.38506,317.68111 522.57102,320.74719 520,324.375 526.44168,318.55721 534.375,312.125 539.6875,308.9375 551.3125,302.0625 564.24236,294.95952 573.99236,291.39702 585.0165,287.93541 596.40861,284.84911 608.05486,282.02202 z"
HorizontalAlignment="Right"
Height="42.353"
Margin="0,281.772,375.32,0"
Stretch="Fill"
VerticalAlignment="Top"
Width="88.055"
Fill="{DynamicResource ブラシ_肌_輪郭}" />
</Grid>
<Grid x:Name="メガネ" Visibility="Visible">
<Path Data="M470.66667,442 C489.99956,414.99987 516.99964,416.33292 536.6663,423.99983"
Height="30.795"
Margin="466.667,415.205,443.336,0"
StrokeStartLineCap="Round"
Stretch="Fill"
StrokeEndLineCap="Round"
Stroke="{DynamicResource ブラシ_メガネ_フレーム}"
StrokeThickness="8"
VerticalAlignment="Top" />
<Path Data="M319.45526,442.15326 C308.78701,444.48658 309.1208,458.15328 322.45549,456.15327"
HorizontalAlignment="Left"
Height="22.199"
Margin="338.246,434.487,0,0"
Stretch="Fill"
Stroke="{DynamicResource ブラシ_メガネ_フレーム}"
StrokeThickness="8"
VerticalAlignment="Top"
Width="18.544"
Fill="{DynamicResource ブラシ_メガネ_フレーム}" />
<Path Data="M457.63243,407.7572 C473.56779,424.49141 475.58467,441.70037 460.46968,458.64415 454.9635,464.81653 447.12214,468.48669 437.94534,471.65674 423.76334,476.49504 409.58134,480.83282 393.56402,480.66614 375.36681,480.8624 362.49798,473.45739 354.35485,459.31087 349.82769,449.95802 349.20665,439.22468 352.01892,427.27797"
HorizontalAlignment="Left"
Margin="348.327,403.257,0,477.828"
Stretch="Fill"
Width="126.438"
Stroke="{DynamicResource ブラシ_メガネ_フレーム}"
StrokeThickness="8"
StrokeStartLineCap="Round"
StrokeEndLineCap="Round"
Fill="{DynamicResource ブラシ_メガネ_レンズ}" />
<Path Data="M643.75,374.25 C655.5872,383.79968 659.50423,396.33091 655.75,411.75 651.50031,427.25054 640.75028,435.00062 625.25,442 575.75011,458.75086 552.25024,445.50025 543.99993,436.25044 536.00019,427.25 534.70026,409.29596 538.00048,397"
HorizontalAlignment="Right"
Height="83.771"
Margin="0,370.25,322.879,0"
StrokeStartLineCap="Round"
Stretch="Fill"
StrokeEndLineCap="Round"
Stroke="{DynamicResource ブラシ_メガネ_フレーム}"
StrokeThickness="8"
VerticalAlignment="Top"
Width="128.813"
Fill="{DynamicResource ブラシ_メガネ_レンズ}" />
<Path Data="M551.21797,409.6209 C566.12588,405.75086 563.12259,422.43455 554.2182,423.62091"
HorizontalAlignment="Right"
Height="22.581"
Margin="0,379.351,316.297,0"
Stretch="Fill"
Stroke="{DynamicResource ブラシ_メガネ_フレーム}"
StrokeThickness="8"
VerticalAlignment="Top"
Width="18.429"
Fill="{DynamicResource ブラシ_メガネ_フレーム}" />
</Grid>
<Grid x:Name="腕"
HorizontalAlignment="Left"
Height="450.753"
Margin="111.434,0,0,6"
VerticalAlignment="Bottom"
Width="281.175">
<Path Data="M345.66589,763.32958 L351.15058,735.49902 C361.25564,702.29947 397.97808,646.74806 390.65058,643.99902 376.4128,640.57484 364.39874,643.66719 352,655 345.91499,661.69441 337.6944,678.13539 333.21071,680.37736 330.08321,677.97097 325.73727,675.39523 323.5,670.5 L286.12931,564.04495 C279.94869,545.75518 268.73736,512.63691 262.79628,510.98542 257.50487,509.44386 251.50343,510.98542 249.17844,515.63539 247.18558,520.28537 246.83982,529.5 249,537 L262.71321,605.64561 C258.66548,608.62049 252.49983,611.12594 247.39317,611.4996 233.74169,585.89371 218.83682,561.781 202,538.5 189.71242,518.7695 171.62321,502.5161 161,507 155.14976,512.81204 156.62791,522.58384 163,535 157.19023,527.87596 153.13064,523.46604 146.8785,523.60678 140.61957,525.04391 139.27878,533.64878 143,544 154.43085,574.98325 167.48632,607.26135 181.75346,638.27847 181.72174,642.24443 178.87303,646.15147
174.94455,648.65787 170.23736,644.15862 122.86675,595.11544 117.15168,597.17602 111.86314,599.2809 111.34777,603.44645 113.99637,613.36789 115.82296,618.51608 142.9258,655.98898 159,676 168.3017,689.01301 200.04188,772.53014 199.93832,774.53935 201.43832,776.03935 226.59277,791.47854 226.59277,791.47854 L261.21863,787.99103 282.39272,783.00892 299.83021,780.26878 z"
Margin="0,0,0,163.5"
Stretch="Fill"
Stroke="{DynamicResource ブラシ_肌_輪郭}"
Fill="{DynamicResource ブラシ_肌}"
StrokeThickness="2" />
<Path Data="M161.19693,667.18809 C167.28866,667.59892 173.58397,663.15294 174.33301,652.33365 L184.83367,640.6675 C202.70354,623.45212 223.75242,613.71312 245.9932,612.25238 L234.22606,591.08395 C236.32131,614.45042 216.12363,621.11294 202.60611,597.99349 212.0735,627.20168 194.36785,637.38271 173.90399,617.82294 L182.07905,637.01063 C183.06696,641.86495 175.60348,649.33409 173.29838,648.26449 172.75994,659.26726 166.93252,664.3541 161.19693,667.18809 z"
HorizontalAlignment="Left"
Height="77.108"
Margin="49.733,85.838,0,0"
Stretch="Fill"
VerticalAlignment="Top"
Width="85.835"
Fill="{DynamicResource ブラシ_肌_影}" />
<Path Data="M379.61977,671.17386 C370.00621,689.3139 360.20407,708.87709 351.86527,728.59687 347.66375,744.98493 342.75207,755.70079 336.167,763.83333 L269.83277,782.50038 209.11003,788.74841 C187.82743,745.09204 173.50443,700.29293 160.80955,677.47255 L148.57505,660.67832 C155.37852,660.80238 162.81103,665.34474 165.49967,669.16669 175.8793,685.43659 190.16302,718.82546 204.16646,743.83357 211.15944,750.75864 219.38987,755.52214 228.8332,758.16695 236.61562,758.9827 258.37575,753.02558 273.16668,748.83359 279.2638,747.32447 284.90597,742.85961 292.16674,741.83356 301.58357,741.04059 315.10819,745.2574 322.8335,743.83357 331.61983,740.70986 340.74688,732.35893 345.50024,725.83352 z"
Margin="37.143,155.425,11.984,166.25"
Stretch="Fill"
Fill="{DynamicResource ブラシ_肌_影}" />
<Path Data="M261,710 C263.30433,697.32759 267.00026,674.16698 268.83333,673.83333 270.83376,673.16699 310.973,677.93866 331.68094,680.48135 L327.65377,684.45501 C301.929,686.64477 281.21794,694.51094 261,710 z"
HorizontalAlignment="Right"
Height="37.23"
Margin="0,168.523,59.942,0"
Stretch="Fill"
VerticalAlignment="Top"
Width="71.667"
Fill="{DynamicResource ブラシ_肌_影}" />
<Path Data="M333.58897,680.31628 L329.16632,684.83365 C304.65613,687.05495 282.16434,695.20706 262.16036,710.66926"
HorizontalAlignment="Right"
Height="30.334"
Margin="0,175.086,59.026,0"
Stretch="Fill"
VerticalAlignment="Top"
Width="71.416"
Stroke="{DynamicResource ブラシ_肌_輪郭}"
Opacity="0.25" />
<Path Data="M304.41667,656.16667 C305,656.75 324.83299,672.66635 324.83299,672.66635"
HorizontalAlignment="Right"
Height="17.5"
Margin="0,150.92,66.776,0"
Stretch="Fill"
Stroke="{DynamicResource ブラシ_肌_輪郭}"
VerticalAlignment="Top"
Width="21.416"
Opacity="0.25" />
<Path Data="M307.09928,625.0797 L307.25606,657.36 322.27763,669.83147 z"
HorizontalAlignment="Right"
Height="46.175"
Margin="0,119.197,70.423,0"
Stretch="Fill"
VerticalAlignment="Top"
Width="15.954"
Fill="{DynamicResource ブラシ_肌_影}"
UseLayoutRounding="False" />
<Path Data="M190,574 C190.16667,574.66667 209.33333,607.33333 209.33333,607.33333 L210.66702,613.00037 206.83335,608.50032 z"
HorizontalAlignment="Left"
Height="40"
Margin="78.566,68.753,0,0"
Stretch="Fill"
VerticalAlignment="Top"
Width="21.667"
Fill="{DynamicResource ブラシ_肌_輪郭}" />
<Path x:Name="袖"
Data="M189.6667,748.16667 L191,771 C192.53403,780.80951 198.00013,791.50046 198,799.5 L174.5,955 335.5,954.5 330.5,804 C334.00091,788.00047 347.33432,773.66717 350.5,761 L352.83401,733.83365 C349.00099,743.16726 344.82223,752.30248 339,759.5 329.66755,768.50052 307.96298,774.11512 284.66667,776 277.41574,775.61848 269.91878,777.16195 262.90356,780.40871 245.25485,783.32752 218.33342,787.33333 211,782 204.33339,777.33333 196.12511,762.10897 189.6667,748.16667 z"
Height="223.167"
Margin="62.066,0,38.776,0"
Stretch="Fill"
Stroke="{DynamicResource ブラシ_セーター_輪郭}"
StrokeThickness="2"
VerticalAlignment="Bottom"
Fill="{DynamicResource ブラシ_セーター}" />
<Path Data="M226,905.5 C221.67035,892.49022 218.37139,879.66994 217.25,867.25 216.82615,854.69409 217.77876,843.32006 220.25,833.25 234.38346,835.11453 245.73907,835.724 255.25,835.5 271.3015,832.68847 284.84111,830.28494 297.50911,826.02385 267.45459,826.66462 241.9396,826.7298 222.50911,826.02385 217.24557,813.68895 213.12613,797.15563 211.84893,784.14715 206.04007,780.69168 197.71335,766.67239 192.13186,754.52852 L193.0315,772.29983 C194.99506,781.02078 197.90601,788.74754 199.82232,796.89905 L199.75,811 C203.94615,842.31078 213.4264,873.84112 226,905.5 z"
Height="152.917"
Margin="79.733,0,94.109,49.5"
Stretch="Fill"
StrokeThickness="2"
VerticalAlignment="Bottom"
Fill="{DynamicResource ブラシ_セーター_影}" />
<Path Data="M263.14675,605.88479 C266.73449,604.89315 270.81768,604.23431 275.44505,603.941 269.36573,601.96494 264.73109,598.13469 260.74865,593.16515"
HorizontalAlignment="Right"
Height="14.812"
Margin="0,85.838,114.953,0"
Stretch="Fill"
StrokeThickness="2"
VerticalAlignment="Top"
Width="16.656"
Fill="{DynamicResource ブラシ_肌_影}" />
<Path Data="M198.25,801.5 L201.25,814.75 C204.5,822.74999 210.44519,829.0645 216,832.75 222.59485,833.93191 228.79678,834.24189 234.75,834 243.59766,835.70718 251.20775,835.67749 258,834.5 L297,826"
Height="34.839"
Margin="86.816,0,94.609,119.661"
Stretch="Fill"
Stroke="{DynamicResource ブラシ_セーター_輪郭}"
VerticalAlignment="Bottom"
Opacity="0.5" />
<Path Data="M317.66667,822.33333 C321.47937,820.83698 324.8674,818.35339 327.66632,814.50031 329.29657,811.70641 330.20987,809.04498 330.49923,806.5003"
HorizontalAlignment="Right"
Height="17.833"
Margin="0,0,61.109,132.667"
Stretch="Fill"
Stroke="{DynamicResource ブラシ_セーター_輪郭}"
VerticalAlignment="Bottom"
Width="14.833"
Opacity="0.5" />
<Path Data="M198.11047,953.38782 C199.93206,945.20949 204.18443,929.6163 203.25,926.25 196.02118,883.85746 194.58,850.05195 195.5,819.75 L176.61883,953.14148 z"
HorizontalAlignment="Left"
Height="135.625"
Margin="64.316,0,0,1.625"
Stretch="Fill"
StrokeThickness="2"
VerticalAlignment="Bottom"
Width="28.642"
Fill="{DynamicResource ブラシ_セーター_影}" />
</Grid>
</Grid>
</Viewbox>
</UserControl>
</Grid>
</Window>
"@
Add-Type -ReferencedAssemblies $assemblies -TypeDefinition $source -Language CSharp
[Program]::Run($xaml)
pause
|
PowerShellCorpus/GithubGist/goyuix_4199427_raw_26012028162d094b6e3da5e011163251aed42ec9_AddManagedMetadataMapping.ps1
|
goyuix_4199427_raw_26012028162d094b6e3da5e011163251aed42ec9_AddManagedMetadataMapping.ps1
|
# Description: script to create a managed property for search that maps to the Active (ows_RoutingEnabled) site column
# Author: Greg McMurray
# History:
# 2012-12-3: Initial version
# a few convenience variables
$YesNo = [Microsoft.SharePoint.Search.Administration.ManagedDataType]::YesNo
$searchApp = Get-SPEnterpriseSearchServiceApplication
# get reference to "Active" property - internally known as ows_RoutingEnabled
$crawledProperty = Get-SPEnterpriseSearchMetadataCrawledProperty -SearchApplication $searchApp -Name ows_RoutingEnabled
$crawledProperty.IsMappedToContents = $true
$crawledProperty.Update()
# get reference to Active managed property or create if needed
$managedProperty = Get-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $searchApp | ? { $_.Name -eq "Active" }
if ($managedProperty -eq $null) {
$managedProperty = New-SPEnterpriseSearchMetadataManagedProperty -Name Active -SearchApplication $searchApp -Type $YesNo -EnabledForScoping $true
}
#get reference to Active managed property mapping and add ows_RoutingEnabled crawled property if needed
$mapping = Get-SPEnterpriseSearchMetadataMapping -SearchApplication $searchApp -ManagedProperty Active | ? { $_.CrawledPropertyName -eq "ows_RoutingEnabled" }
if ($mapping -eq $null) {
New-SPEnterpriseSearchMetadataMapping -SearchApplication $searchApp -ManagedProperty $managedProperty -CrawledProperty $crawledProperty
} else {
"Warning: mapping already exists between Active and ows_RoutingEnabled"
}
|
PowerShellCorpus/GithubGist/miwaniza_9002529_raw_31455bbee72b750cc948d7db7959edfce044ab23_Login-VaultServer.ps1
|
miwaniza_9002529_raw_31455bbee72b750cc948d7db7959edfce044ab23_Login-VaultServer.ps1
|
#Connecting dll
Add-Type -Path "C:\Program Files (x86)\Autodesk\Autodesk Vault 2014 SDK\bin\Autodesk.Connectivity.WebServices.dll"
#Retreiving read-only credentials
$cred = New-Object Autodesk.Connectivity.WebServicesTools.UserPasswordCredentials ("localhost", "Vault", "Administrator", "", $true)
#Creating manager
$webSvc = New-Object Autodesk.Connectivity.WebServicesTools.WebServiceManager ($cred)
|
PowerShellCorpus/GithubGist/Astn_9b07e331400a679afc9a_raw_ed51bcb0c57ed06fb441a9e55f5fb0f67a8e5129_all-render-nustache.ps1
|
Astn_9b07e331400a679afc9a_raw_ed51bcb0c57ed06fb441a9e55f5fb0f67a8e5129_all-render-nustache.ps1
|
# Get us out of a git directory if we are in one.
#while (( ls -Directory -Hidden -Filter ".git" | measure).Count -gt 0 ) {
# Write-Warning "Moving up a directory because a hidden .git folder was detected"
# $loc = (Get-Location).Path
# Write-Warning "Now at ${loc}"
# cd ..
# }
## pull latest of configuration project
IF ((Test-Path .\configuration) -eq $false) {
# checkout the configuration project
git clone https://bitbucket.org/dealersocket/configuration.git configuration
}
# update the configuration project
Push-Location .\configuration
git pull
Pop-Location
## pull latest of TeamCity project
IF ((Test-Path .\teamcity) -eq $false) {
# checkout the configuration project
git clone https://bitbucket.org/dealersocket/teamcity.git teamcity
}
# update the TeamCity project
Push-Location .\teamcity
git pull
Pop-Location
nuget restore -ConfigFile .\teamcity\NuGet.Config .\teamcity\TeamCity.sln
# build our custom version of nustache.exe
msbuild .\teamcity\Teamcity.sln
# load the dll so we can call functions in it
Add-Type -Path .\teamcity\src\Utilities.TeamCity\bin\Debug\Utilities.TeamCity.dll
$NustacheDataRoot = [System.IO.Path]::Combine((Get-Location).Path, "configuration\Nustache")
ls -Directory |
? { (ls $_ -Directory -Hidden -Filter ".git")} |
? { ($_.Name -ne "configuration") -and ($_.Name -ne "teamcity") } |
% {
# go to that repo
Pushd $_
[Utilities.TeamCity.Nustache]::ValidateAndRender($NustacheDataRoot, (Get-Location).Path, "Local.json")
popd
}
[Utilities.TeamCity.Deploy]::ApplyEnvironmentConfiguration("Local", (Get-Location).Path)
|
PowerShellCorpus/GithubGist/peaeater_8be00dbcf2b0a4a0f28e_raw_33073af2ae8d824a93fca2af89dd378e36a65931_delete-eventlog-source.ps1
|
peaeater_8be00dbcf2b0a4a0f28e_raw_33073af2ae8d824a93fca2af89dd378e36a65931_delete-eventlog-source.ps1
|
<#
Remove log source from Application Event Log - requires ADMIN PRIVILEGES
Peter Tyrrell
#>
param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true,Position=0)]
[string]$logsrc
)
# check for admin
if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Warning ("You do not have admin privileges. Re-run this script as an administrator.")
break
}
try {
[System.Diagnostics.EventLog]::DeleteEventSource($logsrc)
Write-Host ("INFO Deleted '{0}'' from Application Event Log." -f $logsrc)
}
catch {
Write-Host ("INFO The source '{0}' is not registered on the machine." -f $logsrc)
}
|
PowerShellCorpus/GithubGist/DavidWise_4438004_raw_a062b06634c8522ecb6536a91751b3e82f2a6ee6_Highlight-Syntax.ps1
|
DavidWise_4438004_raw_a062b06634c8522ecb6536a91751b3e82f2a6ee6_Highlight-Syntax.ps1
|
# Original Author: Lee Holmes, http://www.leeholmes.com/blog/MorePowerShellSyntaxHighlighting.aspx
# Modified by: Helge Klein, http://blogs.sepago.de/helge/
# (http://blogs.sepago.de/e/helge/2010/01/18/syntax-highlighting-powershell-code-in-html-with-a-powershell-script)
# Modified again by: David Wise, http://blog.davidjwise.com
# Syntax highlights a PowerShell script.
#
# Usage: Supply the script to syntax hightligh as first and only parameter
#
# Output: Copy of original script with extension ".html"
#
# Example: .\Highlight-Syntax.ps1 .\Get-AppVPackageDependencies.ps1
#
# Version history:
#
# 1.2: David Wise
# - Converted to use CSS Classes instead of fixed color values
#
# 1.1:
# - Loading the required assembly System.Web now. This was missing earlier.
#
# 1.0: Initial version
[CmdletBinding()]
param($path)
# Load required assemblies
[void] [System.Reflection.Assembly]::Load("System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
# define the CSS Classes for the various elements. the prefix of 'pshs' is to hopefully make the class names unique in almost any
# environment. It is short for "PowerShell Highlight Syntax"
$styles = "
<style type=""text/css"">
.pshs-Body {
font-size: 12px;
font-family: ""Courier New"",Courier,monospace;
line-height:12px;
}
.pshs-Attribute { color: #ADD8E6; }
.pshs-Command { color: #0000FF; font-weight:bold; }
.pshs-CommandArgument { color: #8A2BE2; }
.pshs-CommandParameter { color: #000080; }
.pshs-Comment { color: #006400; font-style:italic; }
.pshs-GroupEnd { color: #000000; }
.pshs-GroupStart { color: #000000; }
.pshs-Keyword { color: #00008B; }
.pshs-LineContinuation { color: #000000; }
.pshs-LoopLabel { color: #00008B; }
.pshs-Member { color: #000000; }
.pshs-NewLine { color: #000000; }
.pshs-Number { color: #800080; }
.pshs-Operator { color: #A9A9A9; }
.pshs-Position { color: #000000; }
.pshs-StatementSeparator { color: #000000; }
.pshs-String { color: #8B0000; background-color:ECECEC; }
.pshs-Type { color: #008080; }
.pshs-Unknown { color: #000000; }
.pshs-Variable { color: #FF4500; }
</style>
"
# Generate an HTML span and append it to HTML string builder
$currentLine = 1
function Append-HtmlSpan ($block, $tokenColor)
{
if (($tokenColor -eq 'NewLine') -or ($tokenColor -eq 'LineContinuation'))
{
if($tokenColor -eq 'LineContinuation')
{
$null = $codeBuilder.Append('`')
}
$null = $codeBuilder.Append("<br />`r`n")
}
else
{
$block = [System.Web.HttpUtility]::HtmlEncode($block)
if (-not $block.Trim())
{
$block = $block.Replace(' ', ' ')
}
if($tokenColor -eq 'String')
{
$lines = $block -split "`r`n"
$block = ""
$multipleLines = $false
foreach($line in $lines)
{
if($multipleLines)
{
$block += "<BR />`r`n"
}
$newText = $line.TrimStart()
$newText = " " * ($line.Length - $newText.Length) + $newText
$block += $newText
$multipleLines = $true
}
}
$null = $codeBuilder.Append("<span class=""pshs-$tokenColor"">$block</span>")
}
}
function Main
{
$text = $null
if($path)
{
$text = (Get-Content $path) -join "`r`n"
}
else
{
Write-Error 'Please supply the path to the PowerShell script to syntax highlight as first (and only) parameter.'
return
}
trap { break }
# Do syntax parsing.
$errors = $null
$tokens = [system.management.automation.psparser]::Tokenize($Text, [ref] $errors)
# Initialize HTML builder.
$codeBuilder = new-object system.text.stringbuilder
$null = $codeBuilder.Append($styles)
$null = $codeBuilder.Append("<span class=""pshs-Body"">")
# Iterate over the tokens and set the colors appropriately.
$position = 0
foreach ($token in $tokens)
{
if ($position -lt $token.Start)
{
$block = $text.Substring($position, ($token.Start - $position))
$tokenColor = 'Unknown'
Append-HtmlSpan $block $tokenColor
}
$block = $text.Substring($token.Start, $token.Length)
$tokenColor = $token.Type.ToString()
Append-HtmlSpan $block $tokenColor
$position = $token.Start + $token.Length
}
$null = $codeBuilder.Append("</span>");
# Build the entire syntax-highlighted script
$code = $codeBuilder.ToString()
# Replace tabs with three blanks
$code = $code -replace "\t"," "
# Write the HTML to a file
$code | set-content -path "$path.html"
}
. Main
|
PowerShellCorpus/GithubGist/smasterson_9140810_raw_fd489f053ad97da11749a7f1e9da3fd82265d30a_Zip2Email.ps1
|
smasterson_9140810_raw_fd489f053ad97da11749a7f1e9da3fd82265d30a_Zip2Email.ps1
|
# Simple Backup to Email script
# Requirements: 7-Zip to be installed
# User Variables
# Folder to zip and send
$TheFolder = "E:\ZipMe"
# (sub)Folder to exclude
$fExclude = "SkipMe"
# Path to zip file (output)
$theDay = Get-Date -Format "MMddyyyy"
$theTime = Get-Date -Format "HHmmss"
$outfile = "E:\zippedfolder_$theDay-$theTime.bak"
# Path to 7-zip
$7z = "E:\Program Files\7-Zip\7z.exe"
# 7-zip Arguments
$7zArgs = "a", "$outfile", "$TheFolder", "-xr!$fExclude"
# Email setup
$emailsubject = "Archive - " + $TheFolder + " - Rename file extension to .7z"
$sendTo = "youraddy@whoever.com"
$sendFrom = "sender@whoever.com"
$smtpserver = "your.relay.com"
# End User Variables
# Zip it up and save 7z output as email msg body
[string]$Body = & $7z $7zArgs
# Send output to email
send-mailmessage -to $sendTo -from $sendFrom -Subject $emailsubject -smtpserver $smtpserver -Body $Body -Attachments $outfile
#Remove zip file
Remove-Item $outfile
|
PowerShellCorpus/GithubGist/owenbyrne_6895094_raw_6b69fdfa16fe7b9f0655ffcb3d1c82a071546f0d_gistfile1.ps1
|
owenbyrne_6895094_raw_6b69fdfa16fe7b9f0655ffcb3d1c82a071546f0d_gistfile1.ps1
|
# variables
$url = "http://packages.nuget.org/v1/Package/Download/Chocolatey/0.9.8.20"
$chocTempDir = Join-Path $env:TEMP "chocolatey"
$tempDir = Join-Path $chocTempDir "chocInstall"
if (![System.IO.Directory]::Exists($tempDir)) {[System.IO.Directory]::CreateDirectory($tempDir)}
$file = Join-Path $tempDir "chocolatey.zip"
# download the package
Write-Host "Downloading $url to $file"
$downloader = new-object System.Net.WebClient
if (!$downloader.Proxy.IsBypassed($url))
{
$cred = get-credential
$webclient = new-object System.Net.WebClient
$proxyaddress = $webclient.Proxy.GetProxy($url).Authority
Write-host "Using this proxyserver: " $proxyaddress
$proxy = New-Object System.Net.WebProxy($proxyaddress)
$proxy.credentials = $cred.GetNetworkCredential();
$downloader.proxy = $proxy
}
$downloader.DownloadFile($url, $file)
# unzip the package
Write-Host "Extracting $file to $destination..."
$shellApplication = new-object -com shell.application
$zipPackage = $shellApplication.NameSpace($file)
$destinationFolder = $shellApplication.NameSpace($tempDir)
$destinationFolder.CopyHere($zipPackage.Items(),0x10)
# call chocolatey install
Write-Host "Installing chocolatey on this machine"
$toolsFolder = Join-Path $tempDir "tools"
$chocInstallPS1 = Join-Path $toolsFolder "chocolateyInstall.ps1"
& $chocInstallPS1
# update chocolatey to the latest version
Write-Host "Updating chocolatey to the latest version"
cup chocolatey
Write-Host "All done"
|
PowerShellCorpus/GithubGist/Nate630_4977282_raw_7393852585ea3cefecff772e91e1375414dc5458_gistfile1.ps1
|
Nate630_4977282_raw_7393852585ea3cefecff772e91e1375414dc5458_gistfile1.ps1
|
#
# Puts everything in a specific SCOM GROUP in Maintenance Mode for x hours
#
# I'm not sure where I got this....script. Sorry.
#
# Uncomment the 'param' line below if you want to pass values by parameter to this script
#param ($groupName, $MMDurationInHours, $rmsServerName)
$MMDurationInHours = "3"
$rmsServerName = "scom.domain.com"
$groupName = "Group Name you want to put in Maint Mode"
$comment = "Scheduled via windows server task on scom.domain.com" # this comment shows up in the SCOM Console.
#Load the Operations Manager snapin and connect to the Root Management Server
add-pssnapin "Microsoft.EnterpriseManagement.OperationsManager.Client";
Set-Location "OperationsManagerMonitoring::";
$mgConn = New-ManagementGroupConnection -connectionString:$rmsServerName;
if($mgConn -eq $null)
{
[String]::Format("Failed to connect to RMS on '{0}'",$rmsServerName);
return;
}
Set-Location $rmsServerName;
$startTime = [DateTime]::Now
$endTime = $startTime.AddHours($MMDurationInHours)
$MonitoringClassCG = get-monitoringclass | where {$_.DisplayName -eq $groupName}
$MonitoringGUID = get-monitoringobject $MonitoringClassCG.Id
New-MaintenanceWindow -startTime:$startTime -endTime:$endTime -comment:$comment -monitoringObject:$MonitoringGUID
|
PowerShellCorpus/GithubGist/healeyio_6a4f2a8db12ba2a99666_raw_db56822affd1c7bddd964d8c7f62ae2d74eafc38_Update-LyncLocation.ps1
|
healeyio_6a4f2a8db12ba2a99666_raw_db56822affd1c7bddd964d8c7f62ae2d74eafc38_Update-LyncLocation.ps1
|
#requires –Version 3.0
<#
.SYNOPSIS
Updates Lync 2013 Client's location information with geolocation data based on internet ip address.
.DESCRIPTION
The Update-LyncLocation.ps1 script updates the Lync 2013 Client's location information. It uses the
Telize web service to determine your external ip address and then queries Telize to collect publicly
available geolocation information to determine your location. That data is then parsed into usable
information and published to the Lync client.
****Requires Lync 2013 SDK.**** The SDK install requires Visual Studio 2010 SP1. To avoid installing
Visual Studio, download the SDK, use 7-zip to extract the files from the install, and install the MSI
relevant to your Lync Client build (x86/x64).
.INPUTS
None. You cannot pipe objects to Update-LyncLocation.ps1.
.OUTPUTS
None. Update-LyncLocation.ps1 does not generate any output.
.NOTES
Author Name: Andrew Healey (@healeyio)
Creation Date: 2015-01-04
Version Date: 2015-01-26
.LINK
Author: http://healey.io/blog/update-lync-client-location-with-geolocation
Lync 2013 SDK: http://www.microsoft.com/en-us/download/details.aspx?id=36824
IP Geolocation Web Service: http://www.telize.com/
.EXAMPLE
PS C:\PS> .\Update-LyncLocation.ps1
#>
# Verify lync 2013 object model dll is either in script directory or SDK is installed
$lyncSDKPath = "Microsoft Office\Office15\LyncSDK\Assemblies\Desktop\Microsoft.Lync.Model.dll"
$lyncSDKError = "Lync 2013 SDK is required. Download here and install: http://www.microsoft.com/en-us/download/details.aspx?id=36824"
if (-not (Get-Module -Name Microsoft.Lync.Model)) {
if (Test-Path (Join-Path -Path ${env:ProgramFiles(x86)} -ChildPath $lyncSDKPath)) {
$lyncPath = Join-Path -Path ${env:ProgramFiles(x86)} -ChildPath $lyncSDKPath
}
elseif (Test-Path (Join-Path -Path ${env:ProgramFiles} -ChildPath $lyncSDKPath)) {
$lyncPath = Join-Path -Path ${env:ProgramFiles} -ChildPath $lyncSDKPath
}
else {
$fileError = New-Object System.io.FileNotFoundException("SDK Not Found: $lyncSDKError")
throw $fileError
} # End SDK/DLL check
try {
Import-Module -Name $lyncPath -ErrorAction Stop
}
catch {
$fileError = New-Object System.io.FileNotFoundException ("Import-Module Error: $lyncSDKError")
throw $fileError
} # End object model import
} # End dll check
# Check if Lync is signed in, otherwise, nothing to do
$Client = [Microsoft.Lync.Model.LyncClient]::GetClient()
if ($Client.State -eq "SignedIn") {
# Get external ip address
$WanIP = (Invoke-WebRequest -Uri "http://ip4.telize.com/" -UseBasicParsing).Content
# Get geolocation data
$data = Invoke-WebRequest -Uri "http://www.telize.com/geoip/$WanIP" -UseBasicParsing | ConvertFrom-Json
$data
### Format the location from returned geolocation ###
### More Info Here: http://www.telize.com/ ###
# Deal with oddities like anonymous proxies
if (($data.continent_code -eq "--") -or ($data.continent_code -eq $null)) {$location = "$($data.isp)"}
# If the city and state are not null, make it City, State
elseif (($data.region_code -ne $null) -and ($data.city -ne $null)) {$location = "$($data.city), $($data.region_code)"}
# If the city is null but state/region has a value, make it Region, Country
elseif (($data.region -ne $null) -and ($data.city -eq $null)) {$location = "$($data.region), $($data.country_code3)"}
# Else, just output the Country
else {$location = "$($data.country)"}
# Update location in Lync
$LyncInfo = New-Object 'System.Collections.Generic.Dictionary[Microsoft.Lync.Model.PublishableContactInformationType, object]'
$LyncInfo.Add([Microsoft.Lync.Model.PublishableContactInformationType]::LocationName, $location)
$Self = $Client.Self
$Publish = $Self.BeginPublishContactInformation($LyncInfo, $null, $null)
$Self.EndPublishContactInformation($Publish)
}
else {
Write-Warning "Lync must be signed in."
} # End client sign-in check
|
PowerShellCorpus/GithubGist/atifaziz_7809279_raw_38f8c7032884f631f6341dba0a75210653c60776_Touch-Item.ps1
|
atifaziz_7809279_raw_38f8c7032884f631f6341dba0a75210653c60776_Touch-Item.ps1
|
# Copyright (c) 2013 Atif Aziz. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
function Touch-Item
{
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Low')]
param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true,
HelpMessage = "Specifies the path to the item to touch")]
[string[]]$Path,
[switch]$Force = $false
)
PROCESS
{
ForEach ($path In $path)
{
$file = Get-Item $path -ea Stop `
| ? { !$_.PSIsContainer `
-and 0 -eq ($file.Attributes -band ([IO.FileAttributes]::Hidden -bor [IO.FileAttributes]::System)) }
if ($file -eq $null)
{
Write-Verbose "Skipping directory: $path"
continue
}
if (!$pscmdlet.ShouldProcess("$file"))
{
continue
}
$attributes = $file.Attributes
$ro = [IO.FileAttributes]::ReadOnly -eq ($attributes -band [IO.FileAttributes]::ReadOnly)
if ($ro)
{
if (!$force)
{
Write-Warning "Skipping file ""$file"" as it is read-only. Use -Force to still touch the file."
continue
}
$file.Attributes = $attributes -band (-bnot [IO.FileAttributes]::ReadOnly)
}
$file.LastWriteTime = Get-Date
if ($ro)
{
$file.Attributes = $file.Attributes -bor [IO.FileAttributes]::ReadOnly
}
Write-Output $file
}
}
}
<#
dir * | Touch-Item -WhatIf
#>
|
PowerShellCorpus/GithubGist/gravejester_bf39cd17808ae89598d0_raw_17591be0dd06125c430024e71572b62f1b49e762_Invoke-SqlCommand.ps1
|
gravejester_bf39cd17808ae89598d0_raw_17591be0dd06125c430024e71572b62f1b49e762_Invoke-SqlCommand.ps1
|
function Invoke-SqlCommand{
<#
.SYNOPSIS
Invoke SQL command(s) to a database server.
.DESCRIPTION
This function will take a SQL query and a database connection and rund the SQL query/commands and optionally return data as a DataTable object.
.EXAMPLES
Invoke-SqlCommand -Query $myQuery -DBConnection $myDbConnection
This will run the query in $myQuery using the connection object in $myDbConnection. No data will be retuned.
.EXAMPLES
$myData = Invoke-SqlCommand -Query $myQuery -DBConnection $myDBConnection -GetResults
This will run the query in $myQuery using the connection object in $myDbConnection and save the returned data in $myData.
.NOTES
Author: Øyvind Kallstad
Date: 05.02.2015
Version: 1.0
#>
param(
[Parameter(Position = 0, Mandatory = $true)]
[string]$Query,
[Parameter(Position = 1, Mandatory = $true, ValueFromPipeline = $true)]
[System.Data.Common.DBConnection]$DbConnection,
[Parameter()]
[int]$Timeout = 30,
[Parameter()]
[switch]$GetResults = $false
)
try{
$command = $DbConnection.CreateCommand()
$command.CommandText = $Query
$command.CommandTimeout = $Timeout
if ($GetResults){
$dbData = New-Object -TypeName 'System.Data.DataTable'
switch($DbConnection.GetType().Name){
'OracleConnection' {$dataAdapter = New-Object -TypeName 'Oracle.DataAccess.Client.OracleDataAdapter' -ArgumentList $command}
'SqlConnection' {$dataAdapter = New-Object -TypeName 'System.Data.SqlClient.SqlDataAdapter' -ArgumentList $command}
'OdbcConnection' {$dataAdapter = New-Object -TypeName 'System.Data.Odbc.OdbcDataAdapter' -ArgumentList $command}
'MySqlConnection' {$dataAdapter = New-Object -TypeName 'MySql.Data.MySqlClient.MySqlDataAdapter' -ArgumentList $command}
default {
$dataAdapter = $null
Write-Warning -Message "Database connection type '$($DbConnection.GetType().Name)' is not supported by this function"
}
}
if ($dataAdapter){
[void]$dataAdapter.Fill($dbData)
Write-Output (,($dbData))
}
}
else{
[void]$command.ExecuteNonQuery()
}
}
catch{
Write-Warning "At line:$($_.InvocationInfo.ScriptLineNumber) char:$($_.InvocationInfo.OffsetInLine) Command:$($_.InvocationInfo.InvocationName), Exception: '$($_.Exception.Message.Trim())'"
}
}
|
PowerShellCorpus/GithubGist/djcsdy_874592_raw_c4d4616de1ef0075e3ba429383f468661622a8bb_svn-clean.ps1
|
djcsdy_874592_raw_c4d4616de1ef0075e3ba429383f468661622a8bb_svn-clean.ps1
|
svn status |
Select-String '^\?' |
ForEach-Object {
[Regex]::Match($_.Line, '^[^\s]*\s+(.*)$').Groups[1].Value
} |
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
|
PowerShellCorpus/GithubGist/RunnerRick_ea1905d8c1e49be11559_raw_bc2f32293675cf96a3b04f0b2c6cbc4fe09dada0_Microsoft.PowerShell_profile.ps1
|
RunnerRick_ea1905d8c1e49be11559_raw_bc2f32293675cf96a3b04f0b2c6cbc4fe09dada0_Microsoft.PowerShell_profile.ps1
|
function prompt
{
# $user = (get-item env:USERNAME).Value
# $host = (get-item env:COMPUTERNAME).Value
$directoryName = (get-location).Path.Substring((get-location).Path.LastIndexOf("\") + 1)
"$directoryName>"
}
|
PowerShellCorpus/GithubGist/westurner_10950476_raw_fe316fd77d787bdf10c506580691075a2c96961c_cinst_workstation_minimal.ps1
|
westurner_10950476_raw_fe316fd77d787bdf10c506580691075a2c96961c_cinst_workstation_minimal.ps1
|
### PowerShell script to install a minimal Workstation with Chocolatey
# https://chocolatey.org
## To Run This Script:
# 1. Download this PowerShell script
# * Right-click <> ("View Raw") and "Save As" to %USERPROFILE% (/Users/<username>)
# * If Cocolatey is not already installed, see
# "Uncomment to install Chocolatey"
# * If you would like to also install Anaconda
# (Python, IPython, lots of great libraries)
# * Scroll down to "Uncomment to install Anaconda (Python)"
# * Check for the latest download .exe or .zip link at ./downloads
# * Uncomment the two lines for your platform (x86 or x86_64)
# 2. Open a Command Prompt
# * Press 'Windows-R' (Run Command); Type `cmd`; Press <Enter>
# 3. Run this PowerShell Script
# * Type the following command:
# @powershell -NoExit -NoProfile -ExecutionPolicy Bypass -File .\cinst_workstation_minimal.ps1
## Uncomment to install Chocolatey
# @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
# https://http://chocolatey.org/packages/<name>
cinst GnuWin
#cint Gow
cinst sysinternals
cinst 7zip
cinst curl
cinst ConsoleZ
#cinst windbg
#cinst windirstat
#cinst Logrotate
#cinst driverbooster
#cinst drivergenius
#cinst dumo
#cinst MicrosoftSecurityEssentials
#cinst avastfreeantivirus
#cinst avgantivirusfree
#cinst bitdefenderavfree
#cinst clamwin
#cinst f-secureav
#cinst kav
# http://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx
cinst notepadplusplus
#cinst vim
cinst KickAssVim
cinst hg
#cinst tortoisehg
cinst git
#cinst TortoiseGit
#cinst svn
#cinst Tortoisesvn
cinst putty
cinst kitty.portable
cinst winscp
cinst spybot
cinst ccleaner
cinst ccenhancer
#cinst sumo
#cinst Secunia.PSI
#cinst adwcleaner
#cinst jrt
cinst vlc
#cinst camstudio
cinst Firefox
cinst GoogleChrome
#cinst Opera
cinst flashplayerplugin
#cinst flashplayeractivex
#cinst javaruntime
#cinst skype
#cinst pidgin
#cinst miranda
#cinst mirc
#cinst gimp
#cinst paint.net
#cinst inkscape
#cinst freecad
#cinst stellarium
#cinst blender
#cinst avidemux
#cinst handbrake
#cinst mixx
#cinst vvvv
#cinst vvvv-addonpack
#cinst clementine
#cinst iTunes
#cinst spotify
#cinst plexmediaserver
#cinst plex-home-theater
cinst FoxitReader
cinst adobereader
#cinst libreoffice
#cinst zotero-standalone
#cinst anki
#cinst PDFCreator
#cinst gnucash
#cinst thunderbird
#cinst dropbox
#cinst googledrive
#cinst puppet
#cinst mcollective
#cinst saltminion # /master=yoursaltmaster /minion-name=yourminionname
#cinst logstash
#cinst unetbootin
#cinst yumi
#cinst cdburnerxp
#cinst wudt
#cinst WinImage
#cinst ext2explore
#cinst ext2fsd
#cinst packer
#cinst vagrant
#cinst virtualbox
### Uncomment to install Anaconda (Python)
# 1. http://continuum.io/downloads
# 2. http://docs.continuum.io/anaconda/install.html#windows-install
## x86_64
#curl -O http://09c8d0b2229f813c1b93-c95ac804525aac4b6dba79b00b39d1d3.r79.cf1.rackcdn.com/Anaconda-1.9.2-Windows-x86_64.exe
#.\Anaconda-1.9.2-Windows-x86_64.exe /S /D=C:\Anaconda
## x86
#curl -O http://09c8d0b2229f813c1b93-c95ac804525aac4b6dba79b00b39d1d3.r79.cf1.rackcdn.com/Anaconda-1.9.2-Windows-x86.exe
#.\Anaconda-1.9.2-Windows-x86.exe /S /D=C:\Anaconda
|
PowerShellCorpus/GithubGist/jiulongw_0bc4dfe787708dc12b12_raw_138251fa2afff938b56e4819e93942d50a7664e9_CreateRemoteShareFolders.ps1
|
jiulongw_0bc4dfe787708dc12b12_raw_138251fa2afff938b56e4819e93942d50a7664e9_CreateRemoteShareFolders.ps1
|
param (
[parameter(Mandatory = $true)]
[string] $computerName,
[parameter(Mandatory = $false)]
[string] $logShareLocal = "D:\data\BTLUX_Shares\LuxLogShare",
[parameter(Mandatory = $false)]
[string] $logShareName = "LuxLogShare",
[parameter(Mandatory = $false)]
[string] $sanLocal = "D:\data\BTLUX_Shares\BTLUXSAN",
[parameter(Mandatory = $false)]
[string] $sanName = "BTLUXSAN"
)
function CreateShare(
$sharePath,
$shareName,
$computer) {
$Class = "Win32_Share"
$Method = "Create"
$sd = ([WMIClass] "\\$computer\root\cimv2:Win32_SecurityDescriptor").CreateInstance()
$ACE = ([WMIClass] "\\$computer\root\cimv2:Win32_ACE").CreateInstance()
$Trustee = ([WMIClass] "\\$computer\root\cimv2:Win32_Trustee").CreateInstance()
$Trustee.Name = "AIS-BTLUX-Machines-dd"
$Trustee.Domain = "PHX"
$Trustee.SIDString = "S-1-5-21-606747145-1563985344-839522115-3480627"
$ace.AccessMask = 2032127
$ace.AceFlags = 3
$ace.AceType = 0
$ACE.Trustee = $Trustee
$sd.DACL += $ACE.psObject.baseobject
$ACE = ([WMIClass] "\\$computer\root\cimv2:Win32_ACE").CreateInstance()
$Trustee = ([WMIClass] "\\$computer\root\cimv2:Win32_Trustee").CreateInstance()
$Trustee.Name = "_BTLUXSA"
$Trustee.Domain = "PHX"
$Trustee.SIDString = "S-1-5-21-606747145-1563985344-839522115-1382479"
$ace.AccessMask = 2032127
$ace.AceFlags = 3
$ace.AceType = 0
$ACE.Trustee = $Trustee
$sd.DACL += $ACE.psObject.baseobject
$ACE = ([WMIClass] "\\$computer\root\cimv2:Win32_ACE").CreateInstance()
$Trustee = ([WMIClass] "\\$computer\root\cimv2:Win32_Trustee").CreateInstance()
$Trustee.Name = "AIS-BTLUX-Partners"
$Trustee.Domain = "PHX"
$Trustee.SIDString = "S-1-5-21-606747145-1563985344-839522115-3480639"
$ace.AccessMask = 131209
$ace.AceFlags = 3
$ace.AceType = 0
$ACE.Trustee = $Trustee
$sd.DACL += $ACE.psObject.baseobject
$mc = [WmiClass]"\\$Computer\ROOT\CIMV2:$Class"
$InParams = $mc.psbase.GetMethodParameters($Method)
$InParams.Access = $sd
$InParams.MaximumAllowed = $Null
$InParams.Name = $shareName
$InParams.Password = $Null
$InParams.Path = $sharePath
$InParams.Type = [uint32]0
$R = $mc.PSBase.InvokeMethod($Method, $InParams, $Null)
switch ($($R.ReturnValue)) {
0 {Write-Host "Share:$shareName Path:$sharePath Result:Success"; break}
2 {Write-Host "Share:$shareName Path:$sharePath Result:Access Denied" -foregroundcolor red -backgroundcolor yellow;break}
8 {Write-Host "Share:$shareName Path:$sharePath Result:Unknown Failure" -foregroundcolor red -backgroundcolor yellow;break}
9 {Write-Host "Share:$shareName Path:$sharePath Result:Invalid Name" -foregroundcolor red -backgroundcolor yellow;break}
10 {Write-Host "Share:$shareName Path:$sharePath Result:Invalid Level" -foregroundcolor red -backgroundcolor yellow;break}
21 {Write-Host "Share:$shareName Path:$sharePath Result:Invalid Parameter" -foregroundcolor red -backgroundcolor yellow;break}
22 {Write-Host "Share:$shareName Path:$sharePath Result:Duplicate Share" -foregroundcolor red -backgroundcolor yellow;break}
23 {Write-Host "Share:$shareName Path:$sharePath Result:Reedirected Path" -foregroundcolor red -backgroundcolor yellow;break}
24 {Write-Host "Share:$shareName Path:$sharePath Result:Unknown Device or Directory" -foregroundcolor red -backgroundcolor yellow;break}
25 {Write-Host "Share:$shareName Path:$sharePath Result:Network Name Not Found" -foregroundcolor red -backgroundcolor yellow;break}
default {Write-Host "Share:$shareName Path:$sharePath Result:*** Unknown Error ***" -foregroundcolor red -backgroundcolor yellow;break}
}
}
Invoke-Command -ComputerName $computerName -ScriptBlock {
param($path)
$exist = Test-Path $path
if(! $exist) {
New-Item -Path $path -type directory -Force
}
} -ArgumentList $logShareLocal
Invoke-Command -ComputerName $computerName -ScriptBlock {
param($path)
$exist = Test-Path $path
if(! $exist) {
New-Item -Path $path -type directory -Force
}
} -ArgumentList $sanLocal
CreateShare $logShareLocal $logShareName $computerName
CreateShare $sanLocal $sanName $computerName
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.