PowerShell Basics Flashcards

1
Q

Get basic system information, including OS, architecture, version, etc.

A

Get-ComputerInfo

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Retrieve or Check logs for critical system events.

A

Get-EventLog -LogName System -EntryType Error -Newest 10

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

List all installed software on the system.

A

Get-WmiObject -Class Win32_Product

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Check the free and used space on all disks.

A

Get-PSDrive -PSProvider FileSystem

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Create a new user in Active Directory (if you’re using AD).

A

New-ADUser -SamAccountName “newuser” -Name “New User” -GivenName “New” -Surname “User” -UserPrincipalName “newuser@domain.com” -AccountPassword (ConvertTo-SecureString “P@ssword1” -AsPlainText -Force) -Enabled $true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Change the password of an existing user account.

A

Set-ADAccountPassword -Identity “username” -NewPassword (ConvertTo-SecureString “NewPassword123” -AsPlainText -Force)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Add a user to a specific Active Directory group.

A

Add-ADGroupMember -Identity “GroupName” -Members “username”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

List all users in a specific Active Directory group.

A

Get-ADGroupMember -Identity “GroupName”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Start or stop a specific service

A

Start-Service -Name “wuauserv”
Stop-Service -Name “wuauserv”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Retrieve the status of a specific service.

A

Get-Service -Name “wuauserv”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Check if there are any pending Windows updates

A

Get-WindowsUpdate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Install available Windows updates.

A

Install-WindowsUpdate -AcceptAll -AutoReboot

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Perform a backup of a folder or directory using PowerShell.

A

Copy-Item -Path “C:\SourceFolder” -Destination “D:\BackupFolder” -Recurse

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Create a scheduled task to run a script or command at a specified time.

A

$Action = New-ScheduledTaskAction -Execute “powershell.exe” -Argument “C:\Scripts\Backup.ps1”
$Trigger = New-ScheduledTaskTrigger -At 3:00AM -Daily
Register-ScheduledTask -Action $Action -Trigger $Trigger -TaskName “DailyBackup” -User “Administrator” -Password “Password123”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Export all user data from Active Directory to a CSV file.

A

Get-ADUser -Filter * -Property DisplayName, EmailAddress | Export-Csv -Path “C:\UsersExport.csv” -NoTypeInformation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Get the health status of all drives (SMART status).

A

Get-WmiObject -Class Win32_DiskDrive | Select-Object DeviceID, Model, Status

17
Q

Verify the integrity of files using a checksum (e.g., SHA256).

A

Get-FileHash “C:\path\to\file.exe” -Algorithm SHA256

18
Q

Retrieve the last logon time of a specific user.

A

Get-ADUser “username” -Properties LastLogonDate

19
Q

Enable or disable an Active Directory user account.

A

Disable-ADAccount -Identity “username”
Enable-ADAccount -Identity “username”

20
Q

Export comprehensive system information to a text file for reporting purposes.

A

Get-ComputerInfo | Out-File “C:\SystemInfo.txt”