Are you an IT Pro?
 Are you interested in information technologies?
  Technology Stronghold is the right place for you!

Simplify your PowerShell DSC Configurations by using parameterized DSC Resources

Often I can see that DSC adopters use similar code:

Configuration TooVerbose

{

Import-DscResource -ModuleName PSDesiredStateConfiguration

Service abc

{

Name = 'abc'

State = 'Running'

Ensure = 'Present'

}

Service def

{

Name = 'abc'

State = 'Running'

Ensure = 'Present'

}

Service xyz

{

Name = 'abc'

State = 'Running'

Ensure = 'Present'

}

}

The …

Read More

How to fix Could not load file or assembly Microsoft.Isam.Esent.Interop error when you setup PowerShell DSC HTTPS Pull Server

I have just downloaded DSC Resource Kit Wave 10 and I can see that known error when you setup PowerShell Desired State Configuration (DSC) HTTP Pull Server was not fixed yet. The reason is that the resource kit is February release. The error is related to missing Microsoft.Isam.Esent.Interop assembly that is available on Windows 8.1 but not on Windows Server 2012 R2.

There are several possibilities how to fix the issue.

You can download current xPSDesiredStateConfiguration from …

Read More

PowerShell script to get all IIS bindings and SSL certificates

Simple PowerShell script to get all bindings in Internet Information Services (IIS) and SSL certificates.

Import-Module -Name WebAdministration

Get-ChildItem -Path IIS:SSLBindings | ForEach-Object -Process `

{

if ($_.Sites)

{

$certificate = Get-ChildItem -Path CERT:LocalMachine/My |

Where-Object -Property Thumbprint -EQ -Value $_.Thumbprint

[PsCustomObject]@{

Sites = $_.Sites.Value …

Read More

PowerShell Tip - How to install Windows Server roles and features and see parent / child relations as results?

It is very simple...

Install-WindowsFeature -Name AD-Domain-Services, DNS -IncludeManagementTools -OutVariable result -Verbose

Get-WindowsFeature -Name $result.FeatureResult.Name

Note: GUIs are not recommended for the server. Install only AD-Domain-Services, DNS and RSAT-AD-PowerShell on your Windows Server Core and RSAT on your management server.

Display Name Name Install State

------------ …

Read More

PowerShell Tip - Convert Script Block to string or string to Script Block

It is very simple. You just need to create a new instance of System.Management.Automation.ScriptBlock and use Create() method.

PowerShell code

$scriptBlock1 =

{

Get-ChildItem

}

Write-Verbose -Message $scriptBlock1.GetType().FullName -Verbose

$scriptBlockString = $scriptBlock.ToString()

Write-Verbose -Message $scriptBlockString.GetType().FullName -Verbose

$scriptBlock2 = [ScriptBlock]::Create($scriptBlockString)

Write-Verbose -Message $scriptBlock2.GetType().FullName - …

Read More