Skip to content

Instantly share code, notes, and snippets.

@trondhindenes
trondhindenes / publish-SmaV2.1.ps1
Created September 22, 2014 15:25
publish-SmaV2.1.ps1
Function Process-RunbookFolder
{
Param (
$Path,
[switch]$recurse,
$WebServiceEndpoint,
$Credential
)
$allwfs = get-childitem -Path $Path -Recurse:$recurse
$Global:referencelist = New-Object System.Collections.ArrayList
# Check if reboot is required, if so notify CA. The MSFT_ServerManagerTasks provider is missing on client SKUs
$featureData = invoke-wmimethod -EA Ignore -Name GetServerFeature -namespace root\microsoft\windows\servermanager -Class MSFT_ServerManagerTasks
$regData = Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" "PendingFileRenameOperations" -EA Ignore
if(($featureData -and $featureData.RequiresReboot) -or $regData)
{
Write-Verbose $LocalizedData.MachineRequiresReboot
$global:DSCMachineStatus = 1
}
# Script to set a windows computer up for remoting
# The script checks the current WinRM/Remoting configuration and makes the necessary changes
# set $VerbosePreference="Continue" before running the script in order to see the output of the script
#
# Written by Trond Hindenes <trond@hindenes.com>
#
# Version 1.0 - July 6th, 2014
Param (
Workflow NonTerminatingFail1
{
new-item -ItemType file -Path "Z:\snakkes.txt"
Write-Output "The script continued"
}
Workflow TerminatingFail1
{
Param ($FirstNumber,$SecondNUmber)
workflow testwf
{
$result = Invoke-restmethod -Uri "http://opendatasalutedata.cloudapp.net/v1/datacatalog/"
$out = $result.service.workspace.collection
$out
}
function testfunc
{
workflow testwf
{
$out = inlinescript {
$result = Invoke-restmethod -Uri "http://opendatasalutedata.cloudapp.net/v1/datacatalog/"
$out = $result.service.workspace.collection
$out
}
$out
}
#!powershell
# This file is part of Ansible.
#
# Copyright 2014, Paul Durivage <paul.durivage@rackspace.com>
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
Function Process-RunbookFolder
{
Param (
$Path,
[switch]$recurse,
$WebServiceEndpoint,
$Credential,
[switch]$force
)
$allwfs =@()
Workflow Dummy-WFInner
{
Param (
[Parameter(Mandatory=$true)]
[PsCredential]$credential,
[Parameter(Mandatory=$true)]
[String]$subscriptionid,
[Parameter(Mandatory=$true)]
@trondhindenes
trondhindenes / testwaitwinrm.yml
Created June 19, 2015 13:12
Ansible play to wait for Windows nodes to come online
---
- name: Wait for windows reboot
hosts: windows
gather_facts: False
tasks:
- shell: 'curl -s -f -k --header "Content-Type: application/soap+xml;charset=UTF-8" --header "WSMANIDENTIFY: unauthenticated" https://{{ ansible_ssh_host }}:{{ ansible_ssh_port }}/wsman --data "<s:Envelope xmlns:s=http://www.w3.org/2003/05/soap-envelope xmlns:wsmid=http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd><s:Header/><s:Body><wsmid:Identify/></s:Body></s:Envelope>" || true'
register: result2
until: result2.stdout.find("Microsoft Corporation") != -1
retries: 30