Skip to main content

Posts

Showing posts with the label GPO

PowerShell search files/folder names with regex

Searching files with regex will come in handy provided you know the pattern you want to look for.
Searching for files that you don't have any clue or idea which one to find is such a dreadful situation.
Regex will help to filter files base on the pattern set from a fragmented memory due to multi-tasking world.
For example, you are quite sure that the file you're looking for starts with s and followed by letter k.
So files like skype_password.txt, skew animation.mp4, skbanner.logo, skin.css, skilled-listing.docx or any files that begins with "sk" will be filtered.
Here's the PowerShell code to do it:
#===================
$regx_filters = get-childitem "c:\all_files_n_rumble\" -recurse | where-object {$_.name -match '^s[k]' } Write-Output $regx_filters
#===================
To get folder or directory names with regex:
#===================
$regexPattern ="^l[i]" Get-ChildItem -Path "c:\all_folder_n_mixes\" -Recurse | Where-Object {$_.PS…

Powershell move selected files

Powershell script below will sort files base on its last write time, it will select the files and move the selected files to another folder.

This script will remove the first 3 old files base on the lastwritetime property, quite useful to archive files or grouping large files into multiple folders.
#=====Code Snippet Start
$xfiles= Get-ChildItem d:\the_log_folder |  Sort-Object -Property @{Expression={$_.LaswriteTime}; Ascending = $true} | Select-Object -first 3 | select fullname | ft -HideTableHeaders
write $xfiles >  d:\move_files_listing.txt
ForEach ($movefiles in (Get-Content "d:\move_files_listing.txt"))
{     
  If ($movefiles[1].Length –gt 0) {
      move-item $movefiles d:\the_archive_folder
      write $movefiles
     }
}
#=====Code Snippet Ends

Code explanation:
--# Sort-Object -Property @{Expression={$_.LaswriteTime}; Ascending = $true # this will sort the files beginning from the file with the  last write time or basically the old files base on its write time.
--# …

Domain Computer takes a long time to login

Login process should be quick and fast, so every user will be happy and start the day smoothly.
But not every day is a new year’s day and there are times that things will just go south and some issues will surface.
Enabling verbose login in local group policy will definitely help to troubleshoot which part of the login process the system halts and takes a long time to process.
Folder redirection for some reason will cause an issue that will take time to load the desktop or causes a login issue.
There are quite a lot of reasons why a GPO takes time to process, and causes login issue.
But if a computer or workstation has been working fine and all of a sudden gives a logon issue; no changes has been made on the server or GPO. Then an issue could occur at the workstation or client side.
One solution that might work on this kind of scenario is to open an elevated command prompt and issue this command on the problematic user computer:
Netsh winsock reset

Normally, the command above is issue…