Posts

Showing posts from 2022

Calling Powershell scripts from C# to monitor IIS Application pool

Image
  Hi All, I recently had a requirement to monitor an application pool in one of our server and if it is gets stopped for some odd reason it must be restarted automatically. I created a windows application to achieve this task. The following are two methods which I used to check the status and if it is stopped to start the application pool.    private string GetpoolStatus(string computerName,string appPoolName)         {             Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace();                          PowerShell powershell = PowerShell.Create();                          PSCommand command = new PSCommand();             string result = "";             ScriptBlock scriptBlock = ScriptBlock.Cre...

Get Remote machine OS Version by querying Active Directory

Image
  Hi All, Recently I had a requirement to find out the OS Version of remote machine but RPC calling were blocked in all machines due to security reasons. So I had to find another way. I achieved this task simply by querying our organisation Active Directory by computer name. I have copied the method I used to achieve this task. public string GetOSVersion(string computername)         {             DirectoryEntry deRoot;             string RootPath;             RootPath = ConfigurationManager.AppSettings["ADPath"];             deRoot = new DirectoryEntry(ConfigurationManager.AppSettings["ADPath"],                                         ConfigurationManager.AppSettings["ADUsername"],                   ...

Azure DevOps - Notification Email not being sent

Image
 Hi Guys, Recently I encountered an issue of Notification Emails not being sent when an event occurred within my companies Azure DevOps environment. After spending hours going through log files, databases still I couldn't find any issue. Finally I went to the DevOps servers and found out the server time was wrong and once I fixed it. We started receiving Notification Emails. Hope this Helps someone    

Error while adding WCF Service Reference in .NET Core projects behind proxy

Image
  Hi All,  I faced this issue while adding WCF Service Reference to my .NET Core application. Since our environment was behind proxy I had to do the following to solve it.   Step 1 -           Go to % AppData %\NuGet\NuGet.Config -           Then add proxy details inside <configuration> < config >          < add key = "http_proxy" value = " http://192.168.21.110:8080 " /> </ config >            Step 2 run the below command in command prompt         dotnet tool install --global dotnet-svcutil          

Powershell script to enumerate Folders/Items within a TFS Project

Image
 Hi, Recently I had a requirement to enumerate folders/Items within a TFS project. The below is the powershell script I used to achieve it. $url = "http://tfsserver:8080/tfs" $folders = Invoke-RestMethod -Uri "$url/CodePortal/QuickWinProjects/_apis/tfvc/items" -Method Get -UseDefaultCredentials -ContentType application/json $folders.value.ForEach({    Write-Host $_.path })

Module to Gzip Compress dynamic aspx pages in Sharepoint

Image
Hi Guys, Recently we had a requirement to compress (gzip) all the dynamic aspx pages within our Sharepoint portal to be compressed before sent to the browser. So this was the module I created to get the task done. Enable Dynamic Page Compression in IIS then add the module in web.config public class GZipCompressionModule : IHttpModule     {         public GZipCompressionModule()         {         }         void IHttpModule.Dispose()         {         }         void IHttpModule.Init(HttpApplication context)         {             context.BeginRequest += Context_BeginRequest;             context.EndRequest += Context_EndRequest;         }         private void Context_BeginRequest(object sender, EventArgs e)     ...

Working with Hot Reload in VS 2019

Image
  Hi Guys, 1)      Please update VS 2019 to Version 16.11.11 by Clicking Help -> Check For Updates 2)       Run your project Make Code Changes Press on the Fire Icon to apply code changes without Restarting Project