Skip to content

Instantly share code, notes, and snippets.

View PlagueHO's full-sized avatar
😼
Working on Game Master Copilot using Semantic Kernel, Azure OpenAI and Blazor 8

Daniel Scott-Raynsford PlagueHO

😼
Working on Game Master Copilot using Semantic Kernel, Azure OpenAI and Blazor 8
View GitHub Profile
@PlagueHO
PlagueHO / Get-HyperVBIOSGUID.ps1
Last active November 29, 2015 22:26
Get the BIOS GUID of a Hyper-V VM
$VMName = 'My VM'
(Get-CimInstance -Namespace Root\Virtualization\V2 -ClassName Msvm_VirtualSystemSettingData -Filter "ElementName = '$VMName'").BiosGUID
@PlagueHO
PlagueHO / FindDSCResources.ps1
Created December 14, 2015 05:03
Search PowerShell Gallery for Modules with the tag DSC
Find-Module -Tag DSC
@PlagueHO
PlagueHO / InstallcFSRMModule.ps1
Created December 14, 2015 05:08
Install cFSRM DSC Resource Module
Install-Module -Name cFSRM
@PlagueHO
PlagueHO / SavecFSRMModule.ps1
Last active December 14, 2015 20:55
Save cFSRM DSC Module
Save-Module -Name cFSRM -Path c:\temp
@PlagueHO
PlagueHO / Sample_ciSCSITarget.ps1
Created December 16, 2015 22:13
Example DSC Configuration of an iSCSI Target
configuration Sample_ciSCSIInitiator
{
Param
(
[String] $NodeName = 'LocalHost'
)
Import-DscResource -Module ciSCSI
Node $NodeName
@PlagueHO
PlagueHO / Example_DSCResourceUnitTest.ps1
Created December 17, 2015 21:37
A Unit test of the xFirewall DSC Resource in the xNetworking module
Describe 'MSFT_xFirewall\Get-TargetResource' {
Context 'Absent should return correctly' {
Mock Get-NetFirewallRule
It "Should return absent on firewall rule $($FirewallRule.Name)" {
$result = Get-TargetResource -Name 'FirewallRule'
$result.Name | Should Be 'FirewallRule'
$result.Ensure | Should Be 'Absent'
}
}
@PlagueHO
PlagueHO / Example_CreateNewUnitTestFromTemplate.ps1
Last active January 24, 2016 23:17
Create a new Unit Test from the DSC Resource unit test template
git clone https://github.com/PowerShell/DSCResources.git
Copy-Item .\DSCResources\Tests.Template\unit_template.ps1 .\ciSCSI\Tests\Unit\BMD_ciSCSIVirtualDisk.Tests.ps1
@PlagueHO
PlagueHO / Example_PullFirewallRulesForDSCUnitTests.ps1
Created December 18, 2015 01:41
Pull Firewall Rules for DSC Unit Tests
# Get the rule that will be used for testing
$FirewallRuleName = (Get-NetFirewallRule | `
Sort-Object Name | `
Where-Object {$_.DisplayGroup -ne $null} | `
Select-Object -first 1).Name
$FirewallRule = Get-FirewallRule -Name $FirewallRuleName
$Properties = Get-FirewallRuleProperty -FirewallRule $FirewallRule
# Pull two rules to use testing that error is thrown when this occurs
$FirewallRules = (Get-NetFirewallRule | `
Sort-Object Name | `
@PlagueHO
PlagueHO / Example_CreateVirtualDiskObjectForDSCUnitTest.ps1
Last active December 20, 2015 23:02
Create a Virtual Disk Object for using in DSC Unit Tests.
# Create the Mock Objects that will be used for running tests
$TestVirtualDisk = [PSObject]@{
Path = Join-Path -Path $ENV:Temp -ChildPath 'TestiSCSIVirtualDisk.vhdx'
Ensure = 'Present'
DiskType = 'Differencing'
SizeBytes = 100MB
Description = 'Unit Test iSCSI Virtual Disk'
BlockSizeBytes = 2MB
PhysicalSectorSizeBytes = 4096
LogicalSectorSizeBytes = 512
@PlagueHO
PlagueHO / Example_DSCUnitTestsForGet-TargetResource.ps1
Last active December 19, 2015 03:53
Example DSC Resource Unit Tests for Get-TargetResource function
Describe "$($Global:DSCResourceName)\Get-TargetResource" {
Context 'Virtual Disk does not exist' {
Mock Get-iSCSIVirtualDisk
It 'should return absent Virtual Disk' {
$Result = Get-TargetResource `
-Path $TestVirtualDisk.Path
$Result.Ensure | Should Be 'Absent'