Code snippet

Open Powershell command line as Admin from a limited user account

Sometimes at work I have to execute something with admin permissions in user’s machines, but normally the final users are not administrators. For these cases my coworkers tell me to log off and switch to an administrator user, but some computers are slow and this process take me minutes.

I wanted to be efficient so I did a research and I found this simple solution: just execute this command:
runas /noprofile /user:DOMAIN\USERNAME "powershell.exe Start-Process powershell.exe -Verb runAs"
(Remember to change DOMAIN\USERNAME with your credentials, you will be asked for the password after executing this command)

The command explained

runas executes something as other user.

The param /noprofile prevents loading the user profile in order to execute anyhing faster. Read this if you are not sure that you can use this param: About User Profiles, or simply remove this param.

"powershell.exe Start-Process powershell.exe -Verb runAs" is the command to be executed. In this case executes a powershell command line with admin privileges. Take in care that it is not possible to execute the command powershell.exe -Verb runAs directly because the powershell window will close immediately.

Code snippet, Programación

Clone Azure DevOps test plans with Powershell

Imagine the situation: You have a test plan in Azure DevOps that is executed every time you create a new version of your product, but Azure DevOps doesn’t provide an easy way to clone test plans and cloning manually is painful.

Fortunately the Azure DevOps REST API has a Clone Operation for test plans: Clone Operation – Clone Test Plan

I wrote a powershell script to make an API call to Clone operation in an easy way, just follow these steps:

  1. Download the script for cloning Azure DevOps Test Plans.
  2. Change these variables values:
    Image of Powershell script with the values for the variables used in this example

    • $organization: Name of the Azure organization of your project. Marked with a green box.
    • $PAT: Your Azure Personal Access Token (PAT). You must set “Test Management permission” to “Read & write”. For more details about PAT follow instructions at Authenticate access with personal access tokens.
    • $project: Project name that contains the test plan. Marked in yellow.
    • $testPlanId: Id of the test plan you want to clone. Marked in red.
    • $testSuiteId: Id of the test suite you want to clone. Marked in purple.

    Image of Powershell script with the parameters marked with colours

Open powershell and execute script, if succeded it will return OK.
After the execution of the Powershell script it returns ok

Clone operation is asyncronous, if the new test plan is empty just wait a few seconds and reload page.
Result of the Powershell script execution