#winrm quickconfig;Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*" -Force;(get-credential).password | ConvertFrom-SecureString | set-content "C:\restartServiceRemote.txt"
$VMIpIs="192.168.100.5"
$VMUser="server\administrator"
$VMPasw=Get-Content "C:\restartServiceRemote.txt" | ConvertTo-SecureString
$VMCred=New-Object Management.Automation.PSCredential ($VMUser,$VMPasw)
#cls
function RestartService {
 Invoke-Command -Credential $VMCred -ComputerName $VMIpIs {
  Restart-Service -Name 'MSSQL$MEDATIXXSQLEXP' -Force
  Restart-Service -Name 'ServiceProvider_261E543B-FFEF-4993-9368-0200B58CE810' -Force
 }
}
RestartService
#pause