Write a powershell script changenames

Assignment Help Programming Languages
Reference no: EM13759955

Part 1: CHANGENAMES.BAT

Create a batch file CHANGENAMES.BAT that does the following (note that %1, %2, and %3 refer to command line arguments passed to the batch file when executed):

Creates a set of %1 empty files with randomly generated names, with filename extension %2.

Uses the dir command to display a list of the file names.

Uses the pause command to pause execution until the user strikes a key.

Changes the filename extension of these files from %2 to %3.

Uses the dir command to display a list of the modified file names.

Pause

Uses the del /p to delete the files with extension %3. The /p option will cause the command to prompt for a confirmation before the deletion of each file.

Part 2: changenames.ps1 and pspause.ps1

Write a PowerShell script changenames.ps1 to repeat the task of the CHANGENAMES.BAT batch file. Note that there is no "pause" command in PowerShell, so you should write your own, with help from Google. Organize this as a separate script file pspause.ps1 and call this script file from the changenames.ps1 script file.

NOTE: you may not call any .bat file from either .ps1 file. (You must solve the pause problem another way.)

Part 3: calc.ps1

Write a PowerShell script named calc.ps1 that performs simple arithmetic calculations of the form

> calc 3 + 4

7
> calc 8 * 3
24
...

You need only support +, -, *, and / operations.

PowerShell Basics

Script Structure

param($p1,$p2,...) ç list of params at the top

function f($a,$b,$c) { ç some function

$result = ...
...

Write-output $result

}

...

function g(...) { ç another function

...

}

... main program ... ç the actual script starts here

Comments

# this is a one liner

<# this

spans multiple lines #>

Comparisons

-eq -ne -lt -le -gt -ge

Boolean Operations

-and -or -not

Boolean Constants

$true $false

Loops

$i = 1

while ($i -le 10) {

Write-output $i

$i++

}

If-Else

if (...) {
...

}

elseif (...) {

...

}

elseif (...) {
...

}

Calling a Function

function f($a, $b, $c) {

...

return ...

}

$x = f 1 2 3 ç don't write f(1,2,3)

Reference no: EM13759955

Questions Cloud

Case study- network infrastructure vulnerabilities : Case Study- Network Infrastructure Vulnerabilities, You are the Information Security Officer at a medium-sized company (1,500 employees)
Write a literary analysis about the value of conflict : Write a Literary Analysis about the value of conflict. We experience conflict in our personal relationships and in our interactions with society.
Case study- ping sweeps and port scans : Case Study: Ping Sweeps and Port Scans, Your boss has just heard about some nefarious computer activities called ping sweeps and port scans
Discuss html- css : As an IT professional, you will frequently use the Web to located resources to help you with your work. There are a plethora of online   resources available, including news articles, reviews, blogs, videos, reference books, and tutorials.
Write a powershell script changenames : Create a batch file CHANGENAMES.BAT that does the following (note that %1, %2, and %3 refer to command line arguments passed to the batch file when executed): Creates a set of %1 empty files with randomly generated names, with filename extension %2..
Health behavior : Health behavior is the activity undertaken by a person who believes him or herself to be healthy for the purpose of preventing health problems.
Impact on the home countrys trade balance : Explain why exchange -rate quotations stated in different financial centers tend to be consistent with one another?
Audit objectives for complex financial instruments : Provide examples of important audit objectives for complex financial instruments and transactions For each audit objective that you identify, list one or more audit procedures that could be used to accomplish that objective.
Compute basic and diluted earnings : Compute basic and diluted earnings per share for 2011. What is meant by dilution of earnings per share?

Reviews

Write a Review

Programming Languages Questions & Answers

  Matlab integration techniques

Use MATLAB integration techniques to determine the total Axial Elongation and explain the theory of Simpson 1/3 rule for integration in detail. Use appropriate examples to demonstrate how it works and how the integration result is computed.

  Find how many words the longest paragraph contains

This def function should search and return the integer that represents this largest length itself. When the passing of (paragraphs) as the argument to this function, it should tell us how many words the longest paragraph contains.

  Create a user interface that uses the gridlayout manager

Define and compile the following two classes that will represent seats in a stadium and When creating a new Stadium, the constructor above will fill a 27x35 two-dimensional array of Seat objects, where each Seat has a number, row and section.

  Write program which accepts input values-store tem in array

Write a program which accepts five input values and stores them into array. Program must display those five numbers in reverse order.

  Design classes account-checkingaccount and savingsaccount

Design and write 3 classes - Account, CheckingAccount, and SavingsAccount. Have CheckingAccount and SavingsAccount inherit from Account.

  Write implementation of counter class

Write the implementation (.cpp file) of the Counter class. Here is the full specification of the class: A data member counter of type int.

  Create structure chart-flowchart to store taxpayer-s name

Create the structure chart, also a flowchart and pseudocode, for following problem. Suppose that each input record contains taxpayer's name.

  How to complete input assertion and output assertion

Complete input assertion and output assertion which will guarantee that student always ends game passing class. Add assertions and invariants which can help reason about claim.

  Logic for a program that allows a user to enter 15 numbers

Design the logic for a program that allows a user to enter 15 numbers, then displays each number and its difference from the numeric average of the numbers entered

  Program to read employee information in the array of objects

Let the program which will read employee information into the array of objects, sort array by employee identification number, write the sorted array.

  Write a function to count the number of times occur

Write a main function to input 20 integers in the range of 1 to 6. Write a function to count the number of times the number 2 and 5 occur. The function should declare static variables count2 and count5. Check the data validity in the main function..

  Weekly demand for motorola cell phones at a retail store is

weekly demand for motorola cell phones at a retail store is normally distributed with a mean of 300 and a standard

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd