This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a hash table for the item and use double quotes | |
$myItem = @{ | |
type = 'Beer' | |
price = '$6.00' | |
} | |
$myString = "The price of a $($myItem.type) is $($myItem.price)" | |
Write-Output $myString |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Escaping the dollar sign using a back-tick | |
$myItem = 'Beer' | |
$myString = "The price of a $myItem is `$6.00" | |
Write-Output $myString |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A Basic String | |
$myString = 'The price of a Beer is $6.00' | |
Write-Output $myString | |
# Using String concatination | |
$myItem = 'Beer' | |
$myString = 'The price of a ' + $myItem + ' is $6.00' | |
Write-Output $myString | |
# Using the format operator |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$title = "This is Matt's Page" | |
$price = 20 | |
$color = 'red' | |
$html = | |
" | |
<HTML> | |
<HEAD> | |
<TITLE>$($title)</TITLE> | |
<BODY> | |
<font color=""$($color)""> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "mwrock/Windows2012R2" | |
config.vm.guest = :windows | |
config.vm.communicator = "winrm" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#---------------------------------------------------------[Initialisations]-------------------------------------------------------- | |
# Makes PowerShell pull you up about everything.. | |
Set-StrictMode -Version Latest | |
# YOu don't need to put this in usually, but just to make sure in your ise. | |
$ErrorActionPreference = "Continue" | |
#Dot Source required Function Libraries | |
#. "Logging_Functions.ps1" | |
#----------------------------------------------------------[Declarations]---------------------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Param | |
( | |
# Param1 help description | |
[Parameter(Mandatory=$true)] | |
$ServiceName | |
) | |
$status = (Get-Service -name $ServiceName) | |
if ($status.Status -ne 'Running') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ensure the build fails if there is a problem. | |
# The build will fail if there are any errors on the remote machine too! | |
$ErrorActionPreference = 'Stop' | |
# Create a password variable using the stored password from the Jenkins Global Passwords | |
$SecurePassword = $env:PasswordForHodge | ConvertTo-SecureString -AsPlainText -Force | |
# If remoting to a machine with domain credentials, use "DOMAIN\YourUserName" | |
# If remoting to a machine on a workgroup, use "\YourUserName" | |
$User = "\Hodge" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ensure the build fails if there is a problem. | |
# The build will fail if there are any errors on the remote machine too! | |
$ErrorActionPreference = 'Stop' | |
# Create a PSCredential Object using the "User" and "Password" parameters that you passed to the job | |
$SecurePassword = $env:Password | ConvertTo-SecureString -AsPlainText -Force | |
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList $env:User, $SecurePassword | |
# Invoke a command on the remote machine. | |
# It depends on the type of job you are executing on the remote machine as to if you want to use "-ErrorAction Stop" on your Invoke-Command. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get a list of trusted hosts | |
Get-Item WSMan:\localhost\Client\TrustedHosts | |
# Note that these commands don't create a list of trusted hosts, it simply replaces the trusted host with what you set via the command. If you need to add multiple hosts, they need to be comma seperated | |
# Trust all computers in a domain | |
Set-Item WSMan:\localhost\Client\TrustedHosts *.contoso.com | |
# Turst a single machine | |
Set-Item WSMan:\localhost\Client\TrustedHosts -Value myserver |