I need to check if I have duplicate passwords from multiple password lists.
I made this command under linux which works sort -u -o dict_sorted_uniqued.txt * but I don't have enough space on the hard drive for it to go all the way.
I cannot find the command to do the same thing with powershell under windows (there I have enough storage to do the manipulation)
I started with a cmd line like this: Get-ChildItem -Recurse | Sort-Object -Unique -Out-File test.txt but it's not good.
Which powershell command should I use?
Update
Yes of course.
I have these files there
Top2Billion-probable-v2.txt
Top109Million-probable-v2.txt
Top12Thousand-probable-v2.txt
Top1575-probable2.txt
Top1pt6Million-probable-v2.txt
Top207-probable-v2.txt
Top29Million-probable-v2.txt
Top2Billion-probable-v2.txt
Top304Thousand-probable-v2.txt
Top353Million-probable-v2.txt
Rockyou.txt
i want to take all unique password and put them in a new file
Related
In the older Windows command prompt dir /w formatted the directory output in wide format, providing a more at-a-glance view of contents to pick out folder names without having to scroll through the larger output that happens when they are all stacked vertically. This is especially useful when in VS Codes integrated terminal where the terminal window size is often restricted. Does PowerShell have an equivilent?
are you after this?
Get-ChildItem | Select-Object -Property Name
It should be an equivalent of "dir /w". If I remember correctly.
cmd /r dir /w as suggested by DSSO21 in the Comments above gives me the result I was expecting, albeit a more verbose command than I'd like.
I'm having trouble moving from command prompt to powershell. Usually I hold the shift key while right clicking, select 'open command prompt here', and use dir /s>filename.txt to get a list of all files in a directory and its subfolders. However, my company just updated our computers and now I can't access the command prompt from the network folder I'm trying to get a directory list of.
When I right click and hold the shift key there is no option to 'open the command prompt' from the folder I'm selecting. I opened command prompt manually and attempted to navigate to the network folder, but no dice. I get an error regarding UNC (?) or that it basically can't do it because it's a network folder.
I attempted to use powershell the same way I use Command prompt given as an answer Here, however I get an error message
PS Microsoft.PowerShell.Core\FileSystem::\\my.company.com\companydata\MainProject\Records\Field Work\Invoices> dir /s >file.txt
dir : Cannot find path 's' because it does not exist.
At line:1 char:1
+ dir /s >file.txt
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (s:String) [Get-ChildItem], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
I also attempted to re-instate the command prompt option in the expanded right-click +shift key list as detailed here. However, I don't have the permissions required to run all the steps.
I just need a directory of everything in a specified network folder, just a list of all the files in the folder and subfolders: file paths, file names, and dates created. I used to be able to get it using command prompt but apparently, that's not available. I'm unsure how to use powershell, and help is much appreciated, in either getting new, simple, easy to understand powershell resources so I can teach myself, or in finding a work around so I can continue using command prompt.
Is there an interpretation guide I can use that goes from Command Prompt to Powershell, and also will let me list files in network drives? (I can sort of understand the current resources out there for having powershell list files in a directory on the computer, but what I need is the powershell to be able to list files in a specified network folder).
In powershell, dir is an alias for Get-ChildItem I believe you're getting that error because switches/arguments work differently in PowerShell. The first parameter by position is Path, so the system thinks you are providing the value /s for the path.
You can do this in PowerShell without having to launch cmd by leveraging Get-ChildItem. As you what the complete structure including the subfolders, user -Recurse
You could also export to csv instead of text file. There's a lot of data - Select can be used to restrict which fields you export.
$Path = "\\my.company.com\companydata\MainProject\Records\Field Work\Invoices"
$Files = Get-ChildItem -Path $Path -Recurse
$Files | Out-file file.txt
$Files | Select-Object FullName,CreationTime | Export-Csv file.csv -NoTypeInformation
I have a script that I run at my work that uses get-childitem to get all the files of a certain type in a storage drive and sorts and moves them to an archive drive. I'd like to automate this process to run once everyday but I realized I would have a problem in doing so.
Occasionally, when this script is run a file or two will still be in the process of transferring over to our storage drive. If I let the script move this file while it is still being transferred from our customer, it gets corrupted and won't open later.
I know how to filter based on file type and date and other basic parameters, but I'm not entirely sure how I tell this script to exclude files that are currently growing in size.
Below is what I'm currently using to filter what I want to move:
$TargetType = "*.SomeFileType"
$TargetDrive = "\\Some\UNC\Path"
Get-ChildItem $targetdrive\$targettype | ForEach-Object {$_.fullname} | Sort-Object | out-file $outStorageMove
Also, at the moment I'm putting everything that get-childitem finds into a text file, that gets invoked later so that I can manually edit what I want it to move. I'd like to get rid of this step if at all possible.
So, move is essentially copy and delete.
So, like gvee state, Copy-Item is a better option, to get you past your stated concern, monitor for the copy to complete. My addition would be to delete once the copy is done and you have verified the copy.
Or use Bits as a job to do this.
Using Windows PowerShell to Create BITS Transfer Jobs
https://msdn.microsoft.com/en-us/library/windows/desktop/ee663885(v=vs.85).aspx
You can use PowerShell cmdlets to create synchronous and asynchronous Background Intelligent Transfer Service (BITS) transfer jobs.
All of the examples in this topic use the Start-BitsTransfer cmdlet. To use the cmdlet, be sure to import the module first. To install the module, run the following command: Import-Module BitsTransfer. For more information, type Get-Help Start-BitsTransfer at the PowerShell prompt.
Powershell is clearly a lot better than cmd but it hides basic functionality. I normally use it to figure out how to use commands that I want in scripts but it breaks a large number of basic things and I end up using both side by side if I hit a sticky spot.
Today this was removing a directory - rd or rmdir - both of which are broken in powershell in favour of one it's undocumented (from the commandline) cmdlets Remove-Item. I seem to run into it all the time though - sc (for mucking around with services); where for finding what program is being called when you type a command etc etc.
Hilariously I actually got the problem with sc and then googled to find out the command where only to discover that didnt work in powershell either! That was a confusing day
In some cases once you know this is what's going on you can type the full exe name (for instance 'where.exe' will work whereas 'where' on its own wont).
This isn't the case with rmdir however. Although interestingly typing 'where rmdir' in cmd doesnt work.
So... my question is this - Is there a way of turning off (preferably all) cmdlets in powershell and just getting the normal stuff instead?
There is no need to turn off cmdlets in powershell as that would destroy the very reason for having it.
Most of the "normal" stuff is there anyway, which you can find by using the get-alias command.
C:\> get-alias
CommandType Name
----------- ----
Alias % -> ForEach-Object
Alias ? -> Where-Object
Alias ?? -> Invoke-NullCoalescing
Alias ac -> Add-Content
Alias asnp -> Add-PSSnapin
Alias cat -> Get-Content
Alias cd -> Set-Location
Alias chdir -> Set-Location
.....
..... AND A WHOLE LOT MORE!
If you are missing a command that you really, really want to have, then you can easily add a new alias:
Set-Alias python2 "C:\Python27\python.exe"
In order to avoid having to do this every single time, you can simply add this into your startup profile. Just type in $PROFILE into the command prompt and it will show you the file path. If it doesn't exist, simply create it, and any powershell commands you add to the top will be automatically invoked when you start a new session.
And last thing. All of the commands are documented, and you can get to them easily using just two.
Just type this into your command prompt and you will be on your way to Powershell enlightenment!
get-help get-command
get-command -noun Item
get-command -verb get
I just realised the answer to my question was buried in the comments to the other answer:
To remove a cmdlet in powershell you run
Remove-Item alias:something.
I can confirm you can do this by using the profile mentioned in Josh's post, however there are a couple more steps:
By default you cant run scripts in powershell. You have to change this using set-ExecutionPolicy.
I changed this by using an admin powershell and typing
set-executionpolicy bypass
This will let you run any script you like
Then in my profile script I have lines like:
Remove-Item -force alias:sc
You wont see errors from this script when it runs and it wont do anything unless you have force.
I use findstr to recursively search several large directories for any lines that match any of the lines in searchList.txt.
findstr /SNIP /D:"C:\search Dir1;C:\search Dir2" /G:C:\searchList.txt *
I want to do the same thing in a Powershell script, either by calling the findstr command or doing something entirely in Powershell. Iterating over each item in searchList.txt and then looking in all the directories is too slow.
How do I call the above line in Powershell, or do the equivalent?
Thanks in advance.
You can call it in PowerShell by opening a PowerShell prompt, typing it in, and hitting [ENTER].
I don't see anything preventing you from running that command from PowerShell. findstr is not a native cmd command, it's a standalone .exe file bundled with Windows and located in the default system path (the System32 directory), so it's available from PowerShell.
You could do it in native PowerShell, but that would be an unnecessary headache. You'd have to do something like this
echo 'C:\search Dir1' 'C:\search Dir2' | Get-ChildItem | Select-String ((Get-Content C:\searchlist.txt) -join '|')
but excluding binary files would be a pain, because AFAIK there's no built-in way to check whether a file is text or binary. If you can rely on the extension, you could add -Filter *.txt after Get-ChildItem.
Bottom line: It's not worth it. Select-String is more versatile in terms of matching patterns, because you can use .NET regular expressions, but if the patterns you want to find are within findstr's limited regex capabilities, you're better off using findstr for this task, and your scripts will be portable because it's always included in Windows.