Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-12-14
3
Medium Priority
?
312 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 668 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 71

Assisted Solution

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

Open in new window

0
 
LVL 71

Accepted Solution

by:
Qlemo earned 1332 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

A procedure for exporting installed hotfix details of remote computers using powershell
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
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ā€¦

670 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