using visual studio code or PowerShell I need to answer the following questions.
ID: 3744330 • Letter: U
Question
using visual studio code or PowerShell I need to answer the following questions.
1. In Powershell command answer the following questions
1.Find the name of the Computername and save it in variable called $ComputerName
example:
$ComputerName = $env: COMPUTERNAME
2. Use $ComputerName to find the fully qualified domain name save the result to the variable name called $DNSFQDN
Here is half complete statement:
$DNSFQDN = Resolve-DnsName
3. $OS = (Get-CimInstance Win32_OperatingSystem -ComputerName $ComputerName).caption
The above command finds the Operating System of the computer using$ComputerName variable as the parameter.
You need to find the how much memory is installed in the computer.
Store the output in the variable called
$Memory = ……. Complete the code
4. You need to find when was the computer last rebooted
$Reboot = ……. Complete the code.
5. You need to find out how much disk space you have in your Drive “C”:
And store the output in a variable name $DriveSpace
$DriveSpace = ……. Complete the code
6. You need to find out who was the last person to log on to this computer:
Save the result in the variable called $lastLogOn
$LastlogOn = ……. Complete the code
7. Print out the value of all the variables with proper prompts.
Example:
$ComputerName = $env:COMPUTERNAME
Write-output "Computername: $Computername"; ""
Explanation / Answer
Answer for the questions are as follows :
1.$ComputerName = ($env:computername) // it will show the computer name
2. $DNSFQDN = ($ComputerName)+"."+(Get-WmiObject win32_computersystem).Domain // this will show the full qualified domain name your pc. note that if yoour powershelkl version is 3 or more you can change " Get-WmiObject" to "Get-CimInstance"
3.$Memory = (Get-WmiObject -Class "win32_PhysicalMemory" -namespace "rootCIMV2" -computerName $ComputerName) // note that if yoour powershelkl version is 3 or more you can change " Get-WmiObject" to "Get-CimInstance"
4. for powershell version 2.0 : $Reboot = Get-WmiObject win32_operatingsystem | select csname, lastbootuptime
For powershell version 3.0 or higher: $Reboot = Get-CimInstance -ClassName win32_operatingsystem | select csname, lastbootuptime
NB: To see what does these variable prints out type " return variable name " ( example: return $ComputerName)
Time allowed 4 questions only.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.