Thursday, May 11, 2017

How to connect Azure subs subscription from PowerShell?

Option 1
To establish connectivity to Azure subscription from PowerShell you need to first run the command  Get-AzurePublishSettingsFile (start PowerShell in  administrator mode). This will result in downloading PublishSettings to your local machine. You can used this file to establish connection to azure by using another azure command Import-AzurePublishSettingsFile
Step
1.       Open PowerShell in administrator  mode
2.       At the Windows PowerShell command prompt, type the below command, and then press Enter
a.  Get-AzurePublishSettingsFile
3.       A web browser opens at https://windows.azure.com/download/publishprofile.aspx for signing in to Windows Azure.
4.       Sign in to the Windows Azure Management Portal, and then follow the instructions to download your Windows Azure publishing settings. Save the file as a .publishsettings type file to your computer.
5.       In the Windows Azure PowerShell window, at the command prompt, type the following command, and then press Enter.
a.  Import-AzurePublishSettingsFile .publishsettings
Replace with the file name of the publishsettings file that you  downloaded in the previous step.
Detail step can be found here https://msdn.microsoft.com/en-us/library/dn385850(v=nav.70).aspx


Another method is to go with Interactive log in by using Connect-AzureRmAccount

Option 2

Step
  1. Type Connect-AzureRmAccount. You will get dialog box asking for your Azure credentials.
  2. Type the email address and password associated with your account. Azure authenticates and saves the credential information, and then closes the window.

Detail step can be found here https://docs.microsoft.com/en-us/powershell/azure/authenticate-azureps?view=azurermps-5.7.0

Friday, March 24, 2017

TLS Cipher Suites in Windows

TLS Cipher Suites in Windows
 
Cipher suite is a concept used in Transport Layer Security (TLS) / Secure Sockets Layer (SSL) network protocol. Its a named combination of authentication, encryption, message authentication code (MAC) and key exchange algorithms used to negotiate the security settings.
 
When a TLS connection is established, a handshaking, known as the TLS Handshake Protocol, occurs. Within this handshake, a client hello (ClientHello) and a server hello (ServerHello) message are passed.[4] First, the client sends a list of the cipher suites that it supports, in order of preference. Then the server replies with the cipher suite that it has selected from the client's list.
 
To know what are the cipher supported by server and client , we can use the below site
 
For Client
 
For Server
 
Additional detail regarding support of cipher on windows can be forum @  https://msdn.microsoft.com/en-us/library/windows/desktop/mt767768(v=vs.85).aspx

Friday, March 10, 2017

How to list certificate installed on my PC using PowerShell.

Use the below code to get the list of certificate installed .

This code gets the children of “Cert:\LocalMachine\my ” , adds the same to an array

$certificates = @{}
Get-ChildItem Cert:\LocalMachine\my | % {
        $cert = $_
        $_.DnsNameList | % {
   
            [string] $dnsName = $_
            $certificates[$dnsName] = $cert.Thumbprint
        }
    }

 $certificates

Tuesday, November 29, 2016

Configuring an Executable to Run as a Service on Windows Server?


Windows NT Resource Kit provides below two utilities that allow you to run an executable as a service

Instrsrv.exe
Srvany.exe
 

More details regarding the same can be found at the below links.


Wednesday, October 26, 2016

Wednesday, September 28, 2016

How to Cast int to enum and back in C#?

How to Cast int to enum and back in C#

To cast an int to enum just do the bellow

MyEnum foo = (MyEnum)myInt;                        

To cast to enum from a string value do the below


MyEnum foo = (MyEnum) Enum.Parse(typeof(MyEnum), myString)

Tuesday, September 27, 2016

How do I convert byte[] to stream in C#?

The easiest way to convert a byte array to a stream is using the MemoryStream class:

Stream stream = new MemoryStream(byteArray);