Question

In: Computer Science

Windows PowerShell Scripting Please answer using a switch statement. I have asked this question already and...

Windows PowerShell Scripting

Please answer using a switch statement. I have asked this question already and it was wrong. Thank you and I will upvote.

1) Write a PowerShell script that displays the total count of each type (dll, txt, log) of files in c:\windows using switch statement.

Solutions

Expert Solution

I have used switch statement and executed all the 3 queries at once. If you want to execute only one or two, you can specify that in switch and give only a single value or two. Please comment if you need any modifications and I'll help you.

$Dir = get-childitem C:\windows # goes to windows directory

$dllList = $Dir | where {$_.extension -eq ".dll"} #get names of all files which has .dll extension
$txtList = $Dir | where {$_.extension -eq ".txt"} #get names of all files which has .txt extension
$logList = $Dir | where {$_.extension -eq ".log"} #get names of all files which has .log extension

switch (1,2,3)
{

    1 {Write-Host "Number of dll files" $dllList.Count}
    2 {Write-Host "Number of txt files"$txtList.Count}
    3 {Write-Host "Number of log files"$logList.Count}
}

If you have any doubts, leave a comment below and I'll help you out.


Related Solutions

BEFORE YOU ANSWER THIS QUESTION, PLEASE READ: I HAVE ALREADY POSTED THIS QUESTION MULTIPLE TIMES, AND...
BEFORE YOU ANSWER THIS QUESTION, PLEASE READ: I HAVE ALREADY POSTED THIS QUESTION MULTIPLE TIMES, AND I NEED HELP WITH THE JOURNAL ENTRIES. PLEASE INCLUDE THEM IN THE ANSWER. THANK YOU Overhead Variances, Four-Variance Analysis, Journal Entries Laughlin, Inc., uses a standard costing system. The predetermined overhead rates are calculated using practical capacity. Practical capacity for a year is defined as 1,000,000 units requiring 200,000 standard direct labor hours. Budgeted overhead for the year is $750,000, of which $300,000 is...
please I want you to answer this question and most importantly, the answer is not already...
please I want you to answer this question and most importantly, the answer is not already available on this site or other site Course Learning Outcome: Apply Organizational behavior knowledge and skills to manage diversified culture in the organizational settings (Lo 2.2). Essay: Differences in Culture and Diversity at workplace Essay Write an essay about the differences in Culture and Diversity at workplace. Use examples, peer-reviewed journals to support your answer. This essay must be at least 1000-word in length....
QUESTION 2: LOAN AMORTIZATION [35 MARKS] Please answer iii only. I already have the answer for...
QUESTION 2: LOAN AMORTIZATION [35 MARKS] Please answer iii only. I already have the answer for i and ii. I. A family buys a house worth $326,000. They pay $75,000 deposit and take a mortgage for the balance at J12=9% p.a. to be amortized over 30 years with monthly payments. A. Find the value of the mortgage on their house? (1 mark) B. Find the value of the monthly payment? C. Find the loan outstanding after making 20 payments? D....
***I understand this question has already been asked, but could I possibly get a new answer?...
***I understand this question has already been asked, but could I possibly get a new answer? I am trying to study a variety of companies and answers so I will be more prepared for whatever is on the test.*** DoorDash as the company. 1. Select a company that has undergone an initial public offering within the last five years and obtain the prospectus (these are usually available on the company’s website, EDGAR for companies listed on the U. S. stock...
***I understand this question has already been asked, but could I possibly get a new answer?...
***I understand this question has already been asked, but could I possibly get a new answer? I am trying to study a variety of companies and answers so I will be more prepared for whatever is on the test.*** DoorDash as the company. 1. Select a company that has undergone an initial public offering within the last five years and obtain the prospectus (these are usually available on the company’s website, EDGAR for companies listed on the U. S. stock...
Please see if you can correct my code. I am getting an ReferenceError in Windows Powershell...
Please see if you can correct my code. I am getting an ReferenceError in Windows Powershell that says payment is undefined. I am trying to create a main.js file that imports the function from the hr.js file; call the function passing the necessary arguments and log the result to the console. main.js var Dev = require("./hr.js") const { add } = require("./hr.js") var dev_type = 1; var hr = 40; console.log("your weekly payment is " + payment(dev_type, hr)) dev_type =...
#2 I post this question twice, please don't answer this post if you already answer the...
#2 I post this question twice, please don't answer this post if you already answer the other one, if you can answer different answer that's fine. REASON WHY I POST IT TWICE, I NEED TWO DIFFERENT VIEW. Discussion: Suicidal Crickets, Zombies Roaches and Other Parasites Tales Please watch the TED Talk ‘Suicidal crickets, zombies roaches and other parasite tales' and post something that you learn as well as whether you believe there could be parasites living inside of humans possibly...
I post this question twice, please don't answer this post if you already answer the other...
I post this question twice, please don't answer this post if you already answer the other one, if you can answer different answer that's fine. REASON WHY I POST IT TWICE, I NEED TWO DIFFERENT VIEW. Discussion: Suicidal Crickets, Zombies Roaches and Other Parasites Tales Please watch the TED Talk ‘Suicidal crickets, zombies roaches and other parasite tales' and post something that you learn as well as whether you believe there could be parasites living inside of humans possibly controlling...
*********Please do not answer the question partially. I have already done step #1, now just needing...
*********Please do not answer the question partially. I have already done step #1, now just needing to complete all of the other steps (2-10)  an explantion included would be nice as well, I would appriciate it! :) *If you can not help completely or entirely; to the furthest extent please do not leave an answer******* Question 1        Required: #1. Prepare journal entries to record the December transactions in the General Journal Tab in the excel template file "Accounting Cycle Excel Template.xlsx"....
*** Please provide computation. I already have the correct answer. With α = .05, what is...
*** Please provide computation. I already have the correct answer. With α = .05, what is the critical t value for a one-tailed test with n = 15?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT