|
| 1 | +--- |
| 2 | +external help file: PSScriptTools-help.xml |
| 3 | +Module Name: PSScriptTools |
| 4 | +online version: |
| 5 | +schema: 2.0.0 |
| 6 | +--- |
| 7 | + |
| 8 | +# Get-FileItem |
| 9 | + |
| 10 | +## SYNOPSIS |
| 11 | + |
| 12 | +A PowerShell version of the Where CLI command |
| 13 | + |
| 14 | +## SYNTAX |
| 15 | + |
| 16 | +### Default (Default) |
| 17 | + |
| 18 | +```yaml |
| 19 | +Get-FileItem [-Pattern] <String[]> [-Regex] [-Full] [-Quiet] [-First] [<CommonParameters>] |
| 20 | +``` |
| 21 | + |
| 22 | +### Path |
| 23 | + |
| 24 | +```yaml |
| 25 | +Get-FileItem [-Pattern] <String[]> [-Regex] [-Path <String[]>] [-Recurse] [-Full] [-Quiet] [-First] |
| 26 | + [<CommonParameters>] |
| 27 | +``` |
| 28 | + |
| 29 | +## DESCRIPTION |
| 30 | + |
| 31 | +This is an enhanced, PowerShell version of the WHERE command from the traditional CLI which will find files in %PATH% that match a particular pattern. |
| 32 | + |
| 33 | +## EXAMPLES |
| 34 | + |
| 35 | +### EXAMPLE 1 |
| 36 | + |
| 37 | +```powershell |
| 38 | +PS C:\> Get-Fileitem notepad.exe |
| 39 | +
|
| 40 | +C:\Windows\system32\notepad.exe |
| 41 | +C:\Windows\notepad.exe |
| 42 | +``` |
| 43 | + |
| 44 | +Find notepad.exe in %path% and return the full file name. This is the default behavior. |
| 45 | + |
| 46 | +### EXAMPLE 2 |
| 47 | + |
| 48 | +```powershell |
| 49 | +PS C:\> PSWhere calculator.exe -quiet |
| 50 | +
|
| 51 | +False |
| 52 | +``` |
| 53 | + |
| 54 | +Search for calculator.exe and return $True if found. This command is using the PSWhere alias. |
| 55 | + |
| 56 | +### EXAMPLE 3 |
| 57 | + |
| 58 | +```powershell |
| 59 | +PS C:\> Get-FileItem "^\d+\S+\.txt" -Regex -path c:\scripts -full |
| 60 | +
|
| 61 | +Directory: C:\scripts |
| 62 | +
|
| 63 | +
|
| 64 | +Mode LastWriteTime Length Name |
| 65 | +---- ------------- ------ ---- |
| 66 | +-a--- 12/5/2007 2:19 PM 30146 1000FemaleNames.txt |
| 67 | +-a--- 12/5/2007 2:19 PM 29618 1000MaleNames.txt |
| 68 | +-a--- 6/2/2010 11:02 AM 31206 1000names.txt |
| 69 | +-a--- 6/3/2010 8:52 AM 3154 100names.txt |
| 70 | +-a--- 4/13/2012 10:27 AM 3781 13ScriptBlocks-v2.txt |
| 71 | +-a--- 8/13/2010 10:41 AM 3958 13ScriptBlocks.txt |
| 72 | +-a--- 2/7/2011 1:37 PM 78542 2500names.txt |
| 73 | +-a--- 2/8/2011 9:43 AM 157396 5000names.txt |
| 74 | +``` |
| 75 | + |
| 76 | +Find all TXT files in C:\Scripts that start with a number and display full file information. |
| 77 | + |
| 78 | +## PARAMETERS |
| 79 | + |
| 80 | +### -Pattern |
| 81 | + |
| 82 | +The name of the file to find. Separate multiple entries with a comma. |
| 83 | +Wildcards are allowed. You can also specify a regular expression pattern by including the -REGEX parameter. |
| 84 | + |
| 85 | +```yaml |
| 86 | +Type: String[] |
| 87 | +Parameter Sets: (All) |
| 88 | +Aliases: |
| 89 | + |
| 90 | +Required: True |
| 91 | +Position: 1 |
| 92 | +Default value: None |
| 93 | +Accept pipeline input: False |
| 94 | +Accept wildcard characters: False |
| 95 | +``` |
| 96 | +
|
| 97 | +### -Regex |
| 98 | +
|
| 99 | +Indicates that the pattern is a regular expression. |
| 100 | +
|
| 101 | +```yaml |
| 102 | +Type: SwitchParameter |
| 103 | +Parameter Sets: (All) |
| 104 | +Aliases: |
| 105 | + |
| 106 | +Required: False |
| 107 | +Position: Named |
| 108 | +Default value: False |
| 109 | +Accept pipeline input: False |
| 110 | +Accept wildcard characters: False |
| 111 | +``` |
| 112 | +
|
| 113 | +### -Path |
| 114 | +
|
| 115 | +The folders to search other than %PATH%. |
| 116 | +
|
| 117 | +```yaml |
| 118 | +Type: String[] |
| 119 | +Parameter Sets: Path |
| 120 | +Aliases: |
| 121 | + |
| 122 | +Required: False |
| 123 | +Position: Named |
| 124 | +Default value: None |
| 125 | +Accept pipeline input: False |
| 126 | +Accept wildcard characters: False |
| 127 | +``` |
| 128 | +
|
| 129 | +### -Recurse |
| 130 | +
|
| 131 | +Used with -Path to indicate a recursive search. |
| 132 | +
|
| 133 | +```yaml |
| 134 | +Type: SwitchParameter |
| 135 | +Parameter Sets: Path |
| 136 | +Aliases: |
| 137 | + |
| 138 | +Required: False |
| 139 | +Position: Named |
| 140 | +Default value: False |
| 141 | +Accept pipeline input: False |
| 142 | +Accept wildcard characters: False |
| 143 | +``` |
| 144 | +
|
| 145 | +### -Full |
| 146 | +
|
| 147 | +Write the full file object to the pipeline. The default is just the full name. |
| 148 | +
|
| 149 | +```yaml |
| 150 | +Type: SwitchParameter |
| 151 | +Parameter Sets: (All) |
| 152 | +Aliases: |
| 153 | + |
| 154 | +Required: False |
| 155 | +Position: Named |
| 156 | +Default value: False |
| 157 | +Accept pipeline input: False |
| 158 | +Accept wildcard characters: False |
| 159 | +``` |
| 160 | +
|
| 161 | +### -Quiet |
| 162 | +
|
| 163 | +Returns True if a match is made. This parameter will override -Full. |
| 164 | +
|
| 165 | +```yaml |
| 166 | +Type: SwitchParameter |
| 167 | +Parameter Sets: (All) |
| 168 | +Aliases: |
| 169 | + |
| 170 | +Required: False |
| 171 | +Position: Named |
| 172 | +Default value: False |
| 173 | +Accept pipeline input: False |
| 174 | +Accept wildcard characters: False |
| 175 | +``` |
| 176 | +
|
| 177 | +### -First |
| 178 | +
|
| 179 | +Stop searching after the pattern is found. Don't search any more paths. |
| 180 | +
|
| 181 | +```yaml |
| 182 | +Type: SwitchParameter |
| 183 | +Parameter Sets: (All) |
| 184 | +Aliases: |
| 185 | + |
| 186 | +Required: False |
| 187 | +Position: Named |
| 188 | +Default value: False |
| 189 | +Accept pipeline input: False |
| 190 | +Accept wildcard characters: False |
| 191 | +``` |
| 192 | +
|
| 193 | +### CommonParameters |
| 194 | +
|
| 195 | +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. |
| 196 | +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). |
| 197 | +
|
| 198 | +## INPUTS |
| 199 | +
|
| 200 | +### Strings |
| 201 | +
|
| 202 | +## OUTPUTS |
| 203 | +
|
| 204 | +### String, Boolean or File |
| 205 | +
|
| 206 | +## NOTES |
| 207 | +
|
| 208 | +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ |
| 209 | +
|
| 210 | +## RELATED LINKS |
| 211 | +
|
| 212 | +[Get-ChildItem]() |
| 213 | +
|
| 214 | +[Where.exe]() |
0 commit comments