ENTER-PSSESSION fails, client not trusted

To enable remote PowerShell session on a client, the client must be trusted.

You might get a similar error message thrown, when using enter-pssession COMPUTER

PowerShellError

The easiest way to get a computer trusted is:

  1. Enable Trused Hosts group policy for Windows Remote Management (WinRM) using gpedit.
    1. Open gpedit.msc and navigate to: Computer Configuration\Administrative Templates\Windows Components\Windows Remote Management (WinRM)\WinRM Client
    2. Set the  Trusted Hosts setting to enabled
    3. Add the IP of the client machine to the TrustedHostsList value, or use * (Asterix) to enable all clients

TrustedHosts

Run a gpupdate /force to reload the group policies. After that you should be able to start a remote session with the client.

Advertisements

Default proxy settings in .Net configuration files

In environments that provide access to the internet through a proxy .Net Assemblies might fail to access the services located on the internet. An easy way to overcome this is to configure the defaultProxy element  in the .Net configuration file for the assembly.

<configuration>
  <system.net>
    <defaultProxy>
      <proxy usesystemdefault="true"
        proxyaddress="http://192.168.1.10:3128"
        bypassonlocal="true" />
      <bypasslist>
        <add address="[a-z]+\.contoso\.com" />
      </bypasslist>
    </defaultProxy>
  </system.net>
</configuration>

The defaultProxy configuration element accepts an address, credentials an optional bypass list.

The configuration can also be inherited by .Net assemblies providing a COM interface if the defaultProxy is configured in the caller’s configuration file.

Passing MSI options through InstallShield setup files

Often MSI installers are wrapped in a boot strap self extracting executable, like InstallShield does it with a setup.exe.

/v

Passing command line options to the wrapped installer through msiexec.exe is straight forward and can be done on the command line by using the /v option. For InstallShield setup executables the call might look like in this example:

setup.exe /v"MSI_PARAM1=0 MSI_PARAM2=MyStringValue"

Note: MSI parameters need to be upper case, otherwise the installer will not find the parameter value in the session.

MSI log

Forcing msiexec to write a log file can be done again by passing the right option to the /v option of the setup executable.

setup.exe /v”MSI_PARAM1=0 MSI_PARAM2=MyStringValue” /v"/l*v c:\test.log"

Silent install
Forcing msiexec to perform a silent or unattended installation is again done by passing the command with the /v option.

setup.exe /v”MSI_PARAM1=0 MSI_PARAM2=MyStringValue" /v"/l*v c:\test.log" /s /v"/qr"

Converting Linux VMWare VM using MVMC 3.0 PowerShell cmdlets

Converting VMs from VMWare to Hyper-V

The most easiest way to convert a VMWare VM is to use Microsoft Virtual Machine Converter 3.0. It comes in two ways, UI and PowerShell Cmdlets. The latter offers more flexibility, especially when the conversion process needs to be automated. Using MVMC you can either just convert a VM or convert and upload directly into Microsoft Azure.

Enable MVMC PowerShell module

1) cd into C:\Program Files\Microsoft Virtual Machine Converter
2) import-module .\MvmcCmdlet.psd1

This example converts a Linux VMWare VM into a Hyper-V VM using a PowerShell ComdLet

ConvertTo-MvmcVirtualHardDisk -DestinationLiteralPath "c:\temp\debian" -SourceLiteralPath "C:\VMs\Debian\disk1.vmdk" -VhdFormat "Vhd" -VhdType FixedHardDisk

Note: In the example I selected the older Vhd format and FixedHardDisk just because these settings are required when importing to Azure. For simple Hyper-V usage VHDX and Dynamic disk size are also possible certainly.

Now you can just create a new VM in Hyper-V Manager and point to the VHD(x) and the VM is available.

SNAGHTML4976a298

image

Uploading a converted VM into Microsoft Azure

Uploading into Azure means basically to upload the VHD into blob storage which then is taken as a base image you point to when creating a new VM. The easiest way to upload a VHD into a blob store is to use Azure CLI.

A command to create an image of the Linux VHD I used earlier looks like this:

azure vm image create DebianImage –blob-url {blobstoreName}/{imageName} –os Linux "c:\temp\debian\disk1.vhd"

With a Windows Server VHD it’s of course much more convenient and can be done from the MVMC UI directly.

Passing arguments to a Windows service installer class using in installutil

Passing parameters to an implementation of the Installer class of a Windows Service executable when installed by the installutil command line tool is pretty easy.

Simply add each parameter and value to the command line, like:

installutil.exe /param1=val1 /param2=val2 serviceexecutable.exe

Note: The parameter arguments needs to be in front of the executable. Otherwise the values will not be passed to the Installer class context.

The installer class implementation can access the arguments conveniently by the context.parameters collection.

image

Restoring a bacpac database backup in SQL Server

SQL database backup in Windows Azure has become super easy. All you need is a database hosted in Azure and a storage account. You can easily configure backup exports on a daily basis and define how long backups should be accessible. But how to restore such a bacpac backup to you on-prem SQL Server?

In Object Explorer select Databases from the Object tree. Choose Import Data-tier-Application and point to the *.bacpac file you downloaded from Azure earlier.

SNAGHTML50dc70

The wizard is mostly self-explanatory, for instance you can change the database name under which the bacpac package should be restored.

Could not find a base address that matches scheme net.pipe for the endpoint with binding NetNamedPipeBinding – WAS and IIS hosting

In most of the cases the error is indicating a missing host/base address section in the config file of the server.

So, simply add a host section to the services section and the define base addresses for http and net pipe like here:

<services>
   <service name="xxxx">
       <host>
           <baseAddresses>
               <add baseAddress="http://localhost:8000/MyService" />
               <add baseAddress="net.tcp://localhost:8100/MyService" />
               <add baseAddress="net.pipe://localhost/" />

But, you can also host a service that is only providing net pipes binding in IIS and benefit from the Windows Process Activation Service (WAS). Using WAS you let IIS control your service and IIS ensures that the service is running and restarted if necessary, all things you need to address in self hosting.

In the case of WAS services you can spare the above, endpoint protocol bindings are in fact defined in IIS and the subject’s exception message is indicating that the net.pipe protocol is not enabled in in the advanced settings of the IIS application. Most probably only the http protocol is enabled, which is the default. Just add net.pipe to the comma separated list and try to browse the service.

SNAGHTML31f444