martes, 14 de septiembre de 2010

BITS command-line

Share it Please

One of the ways to upload/download files to a BITS server is using its command line tool, bitsadmin. You have not confuse this command line with the PowerShell cmdlets that you can use in Windows 7 and 2008. Bitsadmin.exe tool is included by default in Windows XP Service Pack 2, Windows Vista and Windows 2003 Server.

To use it you have to open a cmd console and type the commands you want to use. Bitsadmin uses switches to identify the work to perform, the process is very simple: create a job, enter the different parameters (source, destination, user, etc.) and execute the job.

To upload a file, open a CMD window, type the following sentence and click Enter:

Bitsadmin /create /upload <jobName>

Bitsadmin /create /upload UploadISO

A message similar to that will be displayed showing the ID assigned to the job created

image

Now you have your upload job created so next step is to add to it the file to upload, type a command similar to this one:

Bitsadmin /addfile <jobName> <destination> <file_to_upload>

Bitsadmin /addfile UploadISO https://myServer/ED/SQLR2.iso D:\ISO\SQL_R2.ISO

Now we can add our credentials to the job in case our BITS site implements security:

Bitsadmin /setcredentials <jobName> <authenticationTarget> <authenticationScheme> <user> <password>

Bitsadmin /setcredentials UploadISO SERVER NEGOTIATE dir\myAccount myP@ssword

image

Now we can put, for example, the priority for our job:

Bitsadmin /priority <jobName> <HIGH, NORMAL, LOW, FOREGROUND>

Bitsadmin /priority UploadISO HIGH

image

And now we can run our upload job with /resume or /transfer commands:

Bitsadmin /resume UploadISO

Or

Bitsadmin /transfer UploadISO

As you can guess, playing with the different switch you can create and execute a job using just 2 or 3 lines. For example, you could execute the following lines:

Bitsadmin /create UploadR2

Bitsadmin /transfer UploadR2 /upload /priority HIGH https://myServer/ED/SQLR2.iso D:\ISOs\SQLServer2008_R2.ISO

And evidently if you want to download a file instead to upload it, you have to use the switch /download instead of the /upload one.

Bitsadmin /transfer UploadR2 /download /priority HIGH https://myServer/ED/SQL2008R2.iso C:\Installers\mySQLInstaller.ISO

You can get a complete description of the available switch typing:

Bitsadmin /help

Or

Bitsadmin /?

Also you can get a text version on this link from Microsoft MSDN site: http://msdn.microsoft.com/en-us/library/aa362813(VS.85).aspx

But Bitsadmin.exe is not the only tool we can use to work with BITS, we can use PowerShell and/or some free tools that we will see in the next posts.

No hay comentarios:

Publicar un comentario

Project Mgmt. Professional

Project Mgmt. Professional

AWS Architect

AWS Architect

ITIL Fundamentals

ITIL Fundamentals