Monday, December 19, 2011

Powershell and Atomia Automation Server

First you need to create class library for CoreApiBasicAuth endpoint (use as a help how to do this)

Using this library (for example CoreApiBasicAuth.dll) you can connect to Atomia Automation Server. In following example I created powershell script to list Windows Websites for specific account.

$wsHttpBinding = new-object System.ServiceModel.BasicHttpBinding
$wsHttpBinding.Security.Message.ClientCredentialType = [System.ServiceModel.BasicHttpMessageCredentialType]::UserName
$wsHttpBinding.Security.Mode = [System.ServiceModel.BasicHttpSecurityMode]::TransportWithMessageCredential
$endpoint = new-object System.ServiceModel.EndpointAddress("")

$coreAPI = new-object CoreApiClient($wsHttpBinding, $endpoint)

$Acc = $coreAPI.GetAccount("123456")

#find websites for this account
$pageInfo = New-Object Atomia.Provisioning.Base.PagingInfo 
$strNames = @("CsWindowsWebsite")
$pageInfo.PageSize = 10
$pageInfo.PageNumber = 0
$res = $coreAPI.FindServicesByNamesForAccount($Acc.AccountId, $strNames, [ref] $pageInfo)
$sites = $res | ForEach-Object {$} | Where-Object {$_.Name -eq "Hostname"} | Select-Object propStringValue
Write-Output $sites


Wednesday, November 23, 2011

Using powershell to get IIS worker process

  • Enable execution of powershell scripts with command:
 Set-ExecutionPolicy RemoteSigned
  • Import module for IIS
  import-module webadministration

Now you should be able to see new drive (IIS)


Now, to see worker process for specific pool you only need to execute:

   dir 'IIS:\AppPools\myAppPoolName\WorkerProcesses'

To list all process IDs use:

   dir IIS:\AppPools | Get-ChildItem | Get-ChildItem | Format-Table -AutoSize  processId, appPoolName

Wednesday, September 07, 2011

Export Certificates using Powershell

dir cert:\LocalMachine\My | Where-Object { $_.hasPrivateKey } | Foreach-Object { [system.IO.file]::WriteAllBytes("$home\$($_.SubjectName).pfx", ($_.Export('PFX', '')) ) }

Free partition magic tool

Thursday, September 01, 2011

Convert amr file to mp3

Some android applications may save audio files in amr format. To convert amr file to mp3 file you can use this tool

Monday, April 11, 2011

ID4175: The issuer of the security token was not recognized...

This error is thrown by sts.
Obviously, it is error in  this section:

<issuerNameRegistry type="Microsoft.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, Microsoft.IdentityModel, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
  <add name="CN = test" thumbprint="12 34 56 78 89 45 45 45 45 45 44 44 44" />

At first look thubprint of certificate was OK. But when I open it in hex editor there was some characters that was not visible in text editor. I fix this and everything was OK. :)

Tuesday, March 29, 2011

Flatten objects tree structure

Flatten objects tree structure:

protected IEnumerable<T> Flatten<T>(IEnumerable<T> elements, Func<T, IEnumerable<T>> childrenFunc)
            List<T> result = new List<T>();
            IEnumerable<T> children = elements.SelectMany(childrenFunc);
            if (children.Count() == 0)
                return result;

            result.AddRange(this.Flatten<T>(children, childrenFunc));

            return result;