Quickly produce a list of long file path names.

Here is a quick and easy way to produce a list of long path names from a PS prompt. dir has severation options. File is output in current path as txt file (no sorting).

  1. Run PowerShell (As Admin)
  2. Navigate to folder like C:\Users\Daniel
  3. Run the below

Longer than 260 Characters

cmd /c dir /s /b |? {$_.length -gt 260} > longfilenames.txt

Longer than 150 Characters

cmd /c dir /s /b |? {$_.length -gt 150} > longfilenames.txt
Advertisements

Windows Environment Commands

Windows Environment Commands

These are my most frequently used, often to just get to a location on the SystemRoot quickly. None of these are case sensistive

%USERPROFILE% - Equivalent of ~ on *nix systems.
%WINDIR% - Windows Directory although it seems to hav ebeen superseded by %SystemRoot%
%APPDATA% - Goes to the roaming folder
%LOCALAPPDATA% - goes to the local folder
%LOGONSERVER% -  goes to \\domain_logon_server
%PROGRAMFILES% - C:\Program Files
%PROGRAMFILES(X86)% - C:\Program Files (x86)
%PSModulePath% - Powershell Modules Path

Create a List of installed Software

This time using powershell a list of software can be output to OUT-GridView

Particularly useful to just check remotely or silently using a remote command line. Several ways to output this

1.To WMI Gridview

Get-WmiObject -Class Win32_Product | Select-Object -Property Name, Vendor, InstallDate, Language, Version | Out-GridView

2. To the Screen

Get-WmiObject -Class Win32_Product | Select-Object -Property Name, Vendor, InstallDate, Language, Version

3. To a Text file

Get-WmiObject -Class Win32_Product | Select-Object -Property Name, Vendor, InstallDate, Language, Version 
| Out-File result.txt