Skip to content

Instantly share code, notes, and snippets.

View ps-signed.ps1
$MyCert = new-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\my `
-DnsName api.vm360degee.com `
-friendlyname api.vm360degree.com `
-NotAfter ( [DateTime]::Now.AddYears(5)) `
-KeyAlgorithm RSA `
-KeyLength 2048 `
-KeySpec Signature `
-Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" `
-KeyExportPolicy Exportable `
-KeyUsage DigitalSignature `
View Check-Package.ps1
configuration PackageTest{
param(
[Parameter(Mandatory)] $Machine
)
Import-DscResource –ModuleName 'PSDesiredStateConfiguration'
node $Machine
{
Package PackageExample
@ChabaOk
ChabaOk / Check-Package.ps1
Created Apr 20, 2017
Demonstrate Powershell DSC for Notepad++ installation
View Check-Package.ps1
configuration PackageTest{
param(
[Parameter(Mandatory)] $Machine
)
Import-DscResource –ModuleName 'PSDesiredStateConfiguration'
node $Machine
{
Package PackageExample
@ChabaOk
ChabaOk / set-spooler.ps1
Created Apr 9, 2017
Simple set spooler service in PowerShell DSC
View set-spooler.ps1
Configuration ManagePrintServer
{
param (
[string[]]$NodeName = 'localhost'
)
Import-DscResource –ModuleName 'PSDesiredStateConfiguration'
Node $NodeName
{
Service StartSpooler
@ChabaOk
ChabaOk / addtrustedhost.ps1
Last active Dec 23, 2016
Add winrm trusted host
View addtrustedhost.ps1
Start-Service WinRM
$myTrustWinRM = get-Item WSMan:\localhost\Client\TrustedHosts
if($myTrustWinRM.Value.Length -eq 0)
{
$myNewTrust = "192.168.1.113"
Write-Host "new trustedhosts"
}
else
View new-nanoserver.ps1
$sw = [Diagnostics.Stopwatch]::StartNew()
Import-Module -Name C:\temp\NanoServer\NanoServerImageGenerator
# Prepare password as secure string
$secAdminPassword = ("Passw0rd"|ConvertTo-SecureString -AsPlainText -Force)
# Create Nano image
New-NanoServerImage -MediaPath C:\temp -BasePath .\ -DeploymentType Guest -Edition Standard -TargetPath "c:\temp\NanoVM\vmNanoStorage.vhdx" -AdministratorPassword $secAdminPassword -MaxSize 10GB -storage -ComputerName Nano
# Create VM
$strVM = "Nano"
New-VM -VHDPath c:\temp\nanovm\vmnanostorage.vhdx -MemoryStartupBytes 512MB -Name $strVM -Generation 2
View BuildWindowsContainer.ps1
# This script is from MSDN
Install-WindowsFeatures Containers
#Download docker service and client
Invoke-WebRequest "https://get.docker.com/builds/Windows/x86_64/docker-1.12.1.zip" -OutFile "$env:TEMP\docker-1.12.1.zip" -UseBasicParsing
# Put docker to \Program Files\docker
Expand-Archive -Path "$env:TEMP\docker-1.12.1.zip" -DestinationPath $env:ProgramFiles