Posts

Showing posts from January, 2021

Retrieve Secret from Key-Vault using PowerShell in Azure Runbook

Image
  Today I will showcase to you how to retrieve the Secret from the Key-Vault using PowerShell in Azure Runbook. This is one of the most common scenarios whenever you are writing the script and need credentials for authentication.  Step 1: Check if the following Modules are available in the Azure Runbook AZ.KeyVault AZ.Accounts To check to Navigate to your Automation account, then in the left navigation click on Modules and search for the modules Step 2: If the modules mentioned in Step 1 are not found, then navigate to the " Modules gallery ", search for the modules, and then install. Once installed, re-check for the installed modules as mentioned in step 1.  Step 3: Copy the below script and paste it into your runbook      try  {         $connectionName  =   " AzureRunAsConnection "          # Get the connection "AzureRunAsConnection "         $servicePrincipalConnection  =   Get-AutomationConnection   - Name $connectionName          " Logging in to 

Secure Password with PowerShell encryption

Image
Today we will look into the encryption using PowerShell We usually when working on the elevated privileges, would like to have the security of the script so that the credentials are not compromised. So today I will be discussing it. Machine Specific Encryption The simplest way is to Secure the string and keep that in the file. so then the encrypted string cannot be compromised ENCRYPTION $securePassword  =   " Password@1234 "  |  ConvertTo-SecureString   - AsPlainText  - Force $encrypted  =  $securePassword |  ConvertFrom-SecureString  |  Out-File   - FilePath  " C:\Secured\Encrypted.txt " This will export the password into the encryption format using the default machine keys. to retrieve the password into the plaint text or secure string use the below code DECRYPTION # Returns the password as the secure string $securePassword  =   Get-Content   - Path  " C:\Secured\Encrypted.txt "  |  ConvertTo-SecureString        # Returns the plain text of the pas

Azure runbook script to send mail using PowerShell and SendGrid

Image
 Hi Friends, Today I will be showing how to create and send the mail notification using the SendGrid through Azure Runbook and Powershell SendGrid is a third party API that is very much integrated with Azure and is very easy to use. It provides various ways to send the mail. In this blog, I will be explaining the code to use SendGrid REST API to send the mail. STEPS..!! Step 1: To use SendGrid, you should have 2 things SendGrid Subscription Key: This key will let the SendGrid know the subscription you have and will allow the number of emails accordingly Sender Identity: This identifies the sender so that the mails do not lands up in the SPAM/JUNK folder. To have the above two, you need to login to the SendGrid and follow the instruction. Step 2: Store the Subscription key in Key Vault To maintain the security, I will be keeping the SendGrid Subscription Key into the Azure KeyVault. If you want to do the same, please follow the steps mentioned here Make a note of the two properties that

Comparing List Item count of SharePoint Sites

Image
 Hi friends, When we are migrating we would like to automate as much as possible. One of the processes that I automated was the comparison of the list item count for the two SharePoint sites. Using this PowerShell script will generate the CSV file will all the list differences. This is the quick way of validating the migration of thousands of sites. Happy Coding..!!

Adding Script Editor web part to SharePoint classic page using PowerShell

Image
 Hi friends, When we are migrating the SharePoint on-prem to SharePoint online, we need to tell the users about the site is migrated and there are multiple ways of doing it. One of them is to add the redirection script on the page so that the user will get redirected by itself to the newly migrated site. In this blog, I will be showing how to add the script editor web part using the PowerShell and add the script as well. Problem Statement I have a SharePoint list where all the old sites and new sites are mapped. Need to read all the items and add the script editor web part along with the script for the redirection of the page to the new site URL. Script added - It highlights the page and redirects the user to the new site after 10 seconds. Note: If there is a need to change in the script, do change in the  $WebPartXml  variable. Hope this script will save a lot of time and will help you. Happy Coding..!!