search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Posted in Linux Server, Windows Powershell, Windows Server | No Comment | 2,327 views | 12/06/2014 22:44

This is an example for nxService of PowerShell DSC.

You will able to stop a service like postfix on Linux by using PowerShell DSC.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$cred=Get-Credential -UserName:"root" -Message:"Root User?"
$opt = New-CimSessionOption -UseSsl:$true -SkipCACheck:$true -SkipCNCheck:$true -SkipRevocationCheck:$true
$linuxcomp=New-CimSession -Credential:$cred -ComputerName:linuxdsc.cloudapp.net -Port:5986 -Authentication:basic -SessionOption:$opt
 
Configuration StopService
{
   Import-DSCResource -Module nx
   Node "linuxdsc.cloudapp.net"{    
        nxService StopService
        {
			Name = "postfix"
			Controller = "init"
			State = "Stopped"
        }
    }
}
 
StopService -OutputPath:"C:\temp"
Start-DscConfiguration -CimSession:$linuxcomp -Path:"C:\temp" -Verbose -Wait

After you run DSC, postfix service will be stopped on destination Linux Server.