Skip to main content


Showing posts from May, 2016

Check setting for local group policies

Local group policies define policies for a particular windows system; Set restriction policies, such as limiting number of connection for a remote desktop and other numerous settings that can be set by the system administrator.
The local group policy has a lot of settings to configure and is quite tough to remember those settings unless you have an extraordinary super memory.
Keeping track of the changes in local group policy is important for troubleshooting purposes or if there are some issues that will arise due to policy change.
A proper documentation such as screenshots or other methods is necessary to ease the pain of why and how the problem started.
Windows provided an RSOP tool  to view the list of enabled configuration in group policy settings.
RSOP.msc (resultant set of policy) shows which policy is enabled on the system. So the System Admin can just set and forget which of course not a good practice. But if need to reconfigure but don't know which settings; then run the …

Disconnect Remote Desktop from command line

How to kill remote desktop sessions from the command line?
How to close RDC sessions from the command line?
One solution is to use batch file scripting or use PowerShell.
For old timers batch file might be the preferred solution because you don't need to install anything, it  comes in handy with the native command prompt.
Of course, PowerShell is also one of the best solutions; provided the environment is PowerShell ready.
The method used below utilizes batch file or the command prompt, just like the good old DOS environment of yesterday.
Command below can be run directly from the command prompt.
To use batch file scripting open notepad and save the file with ".bat"  file extension. Once saved as a batch file, the script is ready for automation with the help of Task Scheduler.
Here's the command:
for /f "tokens=2,5" %a in ('netstat -ano ^| find "3389"') do echo %a & tskill %b /v
For folks who just started to embark in batch file world,…

PowerShell Copy Specific File Extension

PowerShell Code snippet to copy files with a particular extension.
$extension = ('.pdf', '.docx', '.txt')
Gci d:\WorkFolder $_ | Where-Object {
$extension -contains $_.Extension
} | % {Copy-Item $_.FullName d:\mix_backup}
To read files with specified filename extension.
$extension = ('.pdf', '.docx', '.txt')
Dir d:\WorkFolder $_ | Where-Object {
$extension -contains $_.Extension

$extension = ('.pdf', '.docx', '.txt')
Gci d:\WorkFolder $_ | Where-Object {
$extension -contains $_.Extension
} | % {write-host $_.FullName }

Copying files with the long path will result to an error.

Robocopy a command line tool is able to copy files exceeding 256 characters.

Below is the modified code that uses robocopy to copy files with long paths.

Do not interchange source and destination when using robocopy, the files will be overwritten.

$extension = ('.pdf', '.jpg', '.txt')
gci d:\WorkFolder $_ | Where-Object {