PowerShell on Linux and Open Source
Hi All,
It’s not a latest news, but still a best news for all scripting lovers. Power shell is now open source project with Linux support.
Power shell is automation scripting language for windows environment, now making its move towards other systems. It’s one of key mile stones in Microsoft.
Below is the information on this.
https://blogs.msdn.microsoft.com/powershell/2016/08/18/powershell-on-linux-and-open-source-2/
At the end ,I want to say everyone who is reading this post : Happy Scripting to All.
Regards,
Chaitanya
Check Remote Servers Ping Status
Hi All,
Below is the sample script for that.
# check the servers are pingable or not
$computers = "Server1","localhost"
$computers | where { -not (Test-Connection $_ -quiet -Count 1)}
Regards,
Chaitanya
How to un Install Applications using PowerShell
Hi All,
Below is the sample script for that. Run this in your local desktop.
# uninstall using Below script
$programs = @(“Google Update Helper”, “Java 7 Update 79 (64-bit)”)
foreach($program in $programs){
$app = Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -like "$program" }
Write-Host "Uniinstalling Application $($app.name)"
$app.Uninstall()
Write-Host "UninStall Complete for app $($App.Name)"
}
Make sure to test it in your local /test server first before doing it in other environments.
Regards,
Chaitanya
How to know Last Boot uptime of servers
Hi All,
Below is the sample script for that. Run this in your local desktop.
$computers = "Server1",”Server2”
$os = Get-CimInstance Win32_operatingSystem -ComputerName $computers
$os | Select Caption,OSArchitecture,InstallDate,LastBootUpTime,@{Name="Uptime";Expression={(Get-Date)-$_.LastBootUpTime}},PSComputername
Regards,
Chaitanya
how to Know FQDN of Server
Hi All,
Below is the sample script for that. Run this in your local desktop.
$server=hostname
[String]$ServerName=[System.Net.Dns]::GetHostEntry([string]$Server).HostName
$ServerName
If you want to know about remote servers, use the invoke-command command let.
Regards,
Chaitanya
Deleting BizTalk Party using PowerShell
Hi All,
Below is the sample script for that.
$BizTalkGroupMgmtDbServerFullName = get-wmiobject MSBTS_GroupSetting -namespace root\MicrosoftBizTalkServer | select-object -expand MgmtDbServerName
$BizTalkGroupMgmtDbName = get-wmiobject MSBTS_GroupSetting -namespace root\MicrosoftBizTalkServer | select-object -expand MgmtDbName
if($BizTalkGroupMgmtDbServerFullName)
{
$BizTalkGroupMgmtDbServerFullNameArr = $BizTalkGroupMgmtDbServerFullName.Split(",")
$BizTalkGroupMgmtDbServerName = $BizTalkGroupMgmtDbServerFullNameArr[0]
}
[void] [System.reflection.Assembly]::LoadWithPartialName("Microsoft.BizTalk.ExplorerOM")
$Catalog = New-Object -TypeName Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer
$Catalog.ConnectionString = "SERVER=$BizTalkGroupMgmtDbServerName;DATABASE=$BizTalkGroupMgmtDbName;Integrated Security=SSPI"
$party = "PartyName"
Write-Host "Started Removing Party : ‘$Party’"
$partyinfo = $Catalog.parties[$Party]
$Catalog.RemoveParty($partyinfo);
$Catalog.SaveChanges();
You might receive this error in this process.
Exception calling "SaveChanges" with "0" argument(s): "The transaction associated with the current connection has completed but has not been disposed. The transaction must be disposed before the connection can
be used to execute SQL statements."
Please check the MSDTC timeout setting. It should be more than a minute.
Regards,
Chaitanya
Test Website Availability using PowerShell
Hi All,
Below is the sample script for that.
$uri = ‘https://www.sqlblogging.com/‘
$data = Invoke-webrequest $uri
$data|select statuscode
StatusCode
Run PowerShell Commands Asynchronously.
Below is the script link for calling PowerShell commands asynchronously without using jobs.
https://gallery.technet.microsoft.com/scriptcenter/Invoke-Async-Allows-you-to-83b0c9f0
Regards,
Chaitanya
How to Get IIS logging Directory/Path using Poweshell
To get the IIS web sites log paths .below is sample PowerShell snippet.
Import-Module WebAdministration
$webistes=get-website
foreach($WebSite in $webistes)
{
$logFile="$($Website.logFile.directory)\w3scv$($website.id)".replace("%SystemDrive%",$env:SystemDrive)
Write-host "$($WebSite.name) [$logfile]"
}
Crediting this snippet to stack over flow site for this.
Regards,
Chaitanya
PowerShell Remoting Kerberos Double Hop Solved Securely
This is the issue has been troubling us over years. Eventually we have a secure solution. Please give it a try in test servers first.
Regards,
Chaitanya