Solved

moving to powershell from dos batch - tutorial / starter advice?

Posted on 2014-12-14
3
274 Views
Last Modified: 2014-12-28
In an other question about stepping through a dos batch file, an expert said

Nowadays you should take the leap to switch to PowerShell.

Got me thinking - I've been making dos batch files since DOS, so I guess I should learn a new skill?

anyone got tips on how to start?  
Is being able to run power shell native to win 7?  XP?  I thought there was something you had to install to get PS to run on a PC? Or maybe just for XP?

What's the extension?

This would empty the windows temp folder, what would it look like as a powershell script?  ANd to run that, you just double click on the file?

Rem Clean windows temp folder
set folder=%windir%\temp
for /f "delims=" %%a in ('dir/ad/b %folder%\*') do (rd /s /q "%folder%\%%a")
del %folder%\*.* /q

 Thanks!
0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 35

Assisted Solution

by:Dan Craciun
Dan Craciun earned 167 total points
ID: 40499145
>>Is being able to run power shell native to win 7? yes, v2. You can get v3 with WinRM

>>XP, no, but you can install WinRM

>>What's the extension? ps1

>>you just double click on the file? not by default. double click will open the file for editing.

$folder=$env:windir + "\temp"
gci $folder -Recurse | %{Remove-Item $_.Fullname -Force}

Open in new window


HTH,
Dan
0
 
LVL 70

Assisted Solution

by:Qlemo
Qlemo earned 333 total points
ID: 40499272
Or, much more simple, just
remove-item -recurse $env:Windir\Temp\*

Open in new window

0
 
LVL 70

Accepted Solution

by:
Qlemo earned 333 total points
ID: 40499281
In regard of some resources:
I recommend to read the EE articles in the PowerShell TA to get an idea how it works.
Make intense use of get-help -detailed for cmdlets you need to know something about.
Get a list of commands which might apply by using e.g. get-command *item*.
Have a look at blogs.technet.com/b/heyscriptingguy/ for some simple, real-life code snippets with explanation.
Subscribe to questions posted in PowerShell here.
And, of course, there is a lot of more out there.
0

Featured Post

Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Utilizing an array to gracefully append to a list of EmailAddresses
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question