Monday, February 9, 2015

What does it mean %* in batch file

%*will return the remainder of the command line starting at the first command line argument (in Windows NT 4, %* also includes all leading spaces)

see Command line parameters

When would you like to use it?One scenario is when you want first to check if util exists and then invoke it with
parameters passed to batch file

Batch file build.cmd
@ECHO OFF
setlocal

set PSakeVersion="4.3.1.0"
set PackagesRoot=%~dp0\..\Source\packages

set PSake=%PackagesRoot%\psake.%PSakeVersion%\tools\psake.cmd
if defined NuGet (
    set NuGet="-nuget %NuGet%"
)

rem check if PSake is downloaded
if not exist %PSake% (
   echo Unable to download PSake using nuget
   goto :EOF
)

echo Invoking PSake build...

%PSake% %~dp0\build.ps1 -framework "4.0" %*


calling batch.cmd
call .\Build\build.cmd PublishBuild -parameters "@{projectName='%ProjectName%';slnName='%SlnName%';platform='%BuildPlatform%';buildConfiguration='%BuildConfiguration%';xsBuildLabel='%system.build.number%';tfExePath='%TFExe%';TeamProjectCollection='$TeamProjectCollection%IsPreRelease%'}" -properties "@{nugetExePath='%env.NuGet%';msbuildLogger='%MSBuildLogger%'}"

It first check if PSake is installed and then run

%PSake% %~dp0\build.ps1 -framework "4.0" @{projectName='%ProjectName%';slnName='%SlnName%';platform='%BuildPlatform%';buildConfiguration='%BuildConfiguration%';xsBuildLabel='%system.build.number%';tfExePath='%TFExe%';TeamProjectCollection='$TeamProjectCollection%IsPreRelease%'}" -properties "@{nugetExePath='%env.NuGet%';msbuildLogger='%MSBuildLogger%'}

Monday, February 2, 2015

Useful powershell command let

Get-Acl 
retrieves security descriptor (access control list) to file, folder or even register key.
e.g.  Get-Acl c:/scropts.txt | Format-List
for more details see https://technet.microsoft.com/en-us/library/ee176838.aspx
       

How to get users belongs to a given User Group?

Use tool from microsoft, named Remote Server Administration Tools for Windows 7 with Service Pack 1 (SP1)
http://www.microsoft.com/en-ca/download/details.aspx?id=7887