Skip to content

Instantly share code, notes, and snippets.

View adbertram's full-sized avatar

Adam Bertram adbertram

View GitHub Profile
$servers = Get-Content -Path C:\servers.txt
$folder = 'C:\Foo'
$user = 'foo'
$pass = 'password'
$secpasswd = ConvertTo-SecureString $pass -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($user, $secpasswd)
$servers | foreach {
##foo.psm1
#####################
$ServiceAppMap = @{
RAS = 'Web' ## DeployWebApplication
EDW = 'Custom' ## Has it's own Install-<App> function
LSA = 'Custom'
LDI = 'Custom'
LDA = 'Web'
LAE = 'Web'
function Get-CacheOptions
{
[CmdletBinding()]
[OutputType('bool')]
param(
[Parameter(Mandatory=$true)]
[System.Web.Services.Protocols.SoapHttpClientProtocol]$ssrsproxy,
[Parameter(Mandatory=$true)]
[string]$path
)
#####################
## Module mymodule.psm1 in C:\Program Files\WindowsPowerShell\Modules\MyModule
function foo {
}
####################
####################
## script.ps1
### foo.ps1
Get-Module
## foo.Tests.ps1
describe 'foo' {
mock 'Get-Module'
(Get-Counter '\Process(*)\% Processor Time').CounterSamples | where { $_.InstanceName -notin @('idle','system','_total') } | sort cookedvalue -Descending | select -first 5 -Property InstanceName,@{n='Percent';e={[math]::Round($_.CookedValue)}}
"Pester - Describe block (Unit Test, Exported Function)": {
"prefix": "descu",
"body": [
"describe '${name}' {",
"",
"\t$$commandName = '${name}'",
"",
"\tcontext 'Help' {",
"\t\t",
play
-----
- name: Folder ACLs
win_acl:
path: "{{ item.value.path }}"
user: "{{ item.value.access.user }}"
rights: "{{ item.value.access.rights }}"
propogation: "{{ item.value.access.propogation }}"
inherit: "{{ item.value.access.inherit }}"
with_dict: "{{ folders|default({}) }}"
## tasks
- name: Setup app pools
win_iiswebapppool:
name: "{{ item.value.name }}"
managed_runtime_version: "{{ item.value.managed_runtime_version }}"
managed_pipeline_mode: "{{ item.value.managed_pipeline_mode }}"
with_dict: "{{ webapppools }}"
## vars
webapppools:
$ErrorActionPreference = "Stop"
try
{
$passedArgs = Parse-Args $args
$definedParams = @(
@{ Name = 'Address'; Mandatory = $true }
@{ Name = 'InterfaceAlias'; Mandatory = $true }
@{ Name = 'State'; Mandatory = $true }