Skip to main content

Posts

PowerShell: Get Strong Random Password

function GetRandomPassword { $ strSrc = ' 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$^&(){}[],. ' $ max = $ strSrc.Length $ strPass = '' for ($ i = 0 ; $ i -lt 20 ; $ i += 1 ) { $ index = Get-Random - Minimum 0 - Maximum $ max $ c = $ strSrc [$ index ] $ strPass += $ c } return $ strPass } create the above function in your powershell profile and you can generate random password at anytime. Happy Coding!!

PowerShell: Get Actual Error

I was having hard time to find the reason why I was not able to find a custom method in a .Net DLL. Find your Assembly: PS C:\vstsagent\A1\_work\r1\a\_DevOps_CI\Scripts > [appdomain]::currentdomain . getassemblies() | Where - Object FullName - Match "MyAssembly" GAC Version Location --- ------- -------- False v4 . 0.30319 C:\vstsagent\A1\_work\r1\a\_DevOps_CI\Scripts\Tools\MyAssembly . dll PS C:\vstsagent\A1\_work\r1\a\_DevOps_CI\Scripts & gt; $ a = [appdomain]::currentdomain . getassemblies() | Where - Object FullName - Match "MyAssembly" PS C:\vstsagent\A1\_work\r1\a\_DevOps_CI\Scripts & gt; $ a GAC Version Location --- ------- -------- False v4 . 0.30319 C:\vstsagent\A1\_work\r1\a\_DevOps_CI\Scripts\Tools\MyAssembly . dll When I was trying to get the Types in the assembly, I was getting the exception: PS C:\vstsagent\A1\_work\r1\a\_DevOps_CI\Scripts > ...

Save User Credentials in Secured File

If you want to save credentials in a file and later want to use it in a script here is the trick. You can use  PowerShell's built-in XML serialization (Clixml): #1. Get The Credentials $cred = Get-Credentails #2. Save the Credentails as a file $cred | Export-CliXml "MyFileName.xml" #3. Read the Credentials back from file $myCred = Import-CliXml "<Path>/MyFileName.xml"

SQL Server | Find all references of a Column

I came across this simple query which can list out all the references columns of a particular column SELECT t.name AS table_name, SCHEMA_NAME(schema_id) AS schema_name, c.name AS column_name FROM sys.tables AS t INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID WHERE c.name LIKE '%ColumnName%' ORDER BY schema_name, table_name; It will give all the reference tablename and schema name along with column name as well

DevOps - What and Why?

The very first question arises in the mind is " What is DevOps? " Few will say it combined team of Developers and Operations. Some will say it is a person "DevOps Engineer" who works with multiple teams to get the things done in corrective manner. Further questions comes in mind are: What is the corrective manner of doing things? How it is different from our "current" method of doing things? Do I need an extra set of tools for this? And, most important of them all, why should I use it? Let me tell you what I've learn in my 3 days of DevOps training. What is DevOps? DevOps is not a team, or tool, DevOps is a culture. It is a culture for collaboration, Integration and Communication between different cross functional teams for  Continuous Delivery . DevOps is not an additional team, but it is the existing team members who work together. It breaks the barrier between Infrastructure and Code at early stage. DevOps also encoura...

Notepad++ Error for 64bit - ShellExecute failed (2): Is this command correct?

Cause : It happens when you set Notepad++ to "run as" administrator on Windows 7. Fix:  To fix this, you need to manually edit the registry of your system to create a new option in pop-up menu to open files with Notepad++ Step 1 : Delete existing  Edit with Notepad++  entry from registry Go into your registry as an administrator (Run -> regedit) and search for notepad++.exe. Find the key under  HKEY_CLASSES_ROOT  that has an entry with the  Edit with Notepad++  (or maybe  Edit with &Notepad++ ) and delete the entire key. Right click and you should see that you no longer have that option. Step 2 : Create new entry Open with Notepad++ Go to: HKEY_CLASSES_ROOT\*\shell Create a new key under shell called  OpenWithNotepad  and create a subkey under that called  command . In the  OpenWithNotepad  key the default string is what you want the context menu item to be called. I set it to  Open with Not...

MS-DOS and INI file

I came into a requirement where I had to separate a DOS batch file and move all the variable and user specific setting into a separate file. So here is the solution: I created a new INI config file and declared my available in it. MyINIFile.ini UserName=MyUserName Datapath=C:\data ServerName=MyServer Here is how I am calling the INI file inside the batch file. MyBatchFile.bat FOR /F "tokens=1,2 delims=^=" %%A IN (MyINIFile.ini) DO (SET %%A=%%B ) ECHO %Datapath% ECHO %ServerName%