Skip to main content


Showing posts with the label Windows. Powershell

PowerShell restart remote server with confirmation

Restart a remote PC or server and ask user to confirm reboot before proceeding.

Here’s the code:
$response_confirmation=[Microsoft.VisualBasic.Interaction]::MsgBox("Restart this server: "+$server_q,'YesNo',"Confirm to reboot?")

switch ( $response_confirmation )
Yes{ Restart-Computer-ComputerName$server_q} No{ Write-Host"Restart Cancelled"} }
Code above will prompt the user with “Yes” or “No”, yes will send the restart or reboot command to the remote server or computer, and no will cancel or exit the execution.

PowerShell code above also demonstrate how to use a switch case statement and use the response to perform an action, in regar

PowerShell check access or folder permissions

In an Active Directory domain, one of the common issues is folder permissions. Of course, permission must be restricted as much as possible. In order, confidential data or things that only a group of people will know, is not made available to everyone.

Employee salaries on a network share made available to everyone, will cause some employees to be disheartened. Such data, the access or folder permission should be checked properly.
One way to check a folder permission is to assume or login as a certain user that is not supposed to have access to such data and checked whether the data can be viewed or not.
Aside from restricting permissions for confidential data; data supposed to be accessed by everyone but some user’s complaint that they are unable to access then this will also cause some problem and may end up not being productive for the users.
One way to check is to go to the user’s workstation and verify whether the user is unable to access. This kind of issue is not hard to solve…

PowerShell Get OneDrive email address

If you have a subscription to Office 365, chances are you have OneDrive configured in your system and is linked to your email address.
OneDrive is quite good since you can have your data on the cloud, of course you also have to use common sense and what data you are uploading to the cloud.
OneDrive will come handy since you just need internet connection and you will be able to retrieve your notes or data anywhere.
But how to check which email address is linked to your OneDrive? Well, there' a simple way using PowerShell to view registry keys.
A one liner PowerShell script will come-in handy to do these kind of task.
Here’s the code, if using Hotmail, or Live email:
For OneDrive Business use this code:


PowerShell get screen resolution

Check screen resolution of the monitor using PowerShell.
Get-WmiObject-Query"Select * from Win32_desktopmonitor"-Namespace'Root\CIMV2'|selectname,screenheight,screenwidth
Sample output:
namescreenheight screenwidth ---------------- ----------- Default Monitor Generic PnP Monitor 10801920

To check remote PCs, use the code below, of course proper credentials is required.
Invoke-Command-ComputerName192.168.1.20-ScriptBlock { Get-WmiObject-Query"Select * from Win32_desktopmonitor"-Namespace'Root\CIMV2'|selectname,screenheight,screenwidth }
Some application requires or either work properly when a particular screen resolution is properly set or configured.
To get more details like video processor, driver version and driver date use the code below. Updating drivers is quite important as it will improve device performance and other update features.
Get-WmiObject-Query"Select caption,driverdate,driverversion,videoprocessor from Win32_videocontroller"-N…

PowerShell check sound devices

PowerShell code below will list the names of the sound devices and its status on the system.
The status might show OK, I believe this refers to the driver installation but if some settings are misconfigured that will be another issue.
Here’s the code:
Get-WmiObject-Query"Select * from Win32_sounddevice"-Namespace'Root\CIMV2'

Sample output:
ManufacturerNameStatus StatusInfo ---------------------- ---------- Intel(R) Corporation Intel(R) Display AudioOK3 (Generic USB Audio)USB Audio DeviceOK3 RealtekRealtek High Definition Audio OK3

Cheers..till next time. :)

================================ Free Android Apps:
Click  links below to find out more:
Excel Keyboard guide:

Heaven's Dew Fall  Prayer app for Android :
Catholic Rosary Guide  for Android: