Windows 10: "dir" like PowerShell script for wrting to a text file

Discus and support "dir" like PowerShell script for wrting to a text file in Windows 10 Gaming to solve the problem; I think I must have re-re-invented a wheel, but I couldn't find such a script.I hope this will help someone lacking the search skill it's me .This is... Discussion in 'Windows 10 Gaming' started by noellapin, Oct 20, 2021.

  1. noellapin Win User

    "dir" like PowerShell script for wrting to a text file


    I think I must have re-re-invented a wheel, but I couldn't find such a script.I hope this will help someone lacking the search skill it's me .This is for writing to a text file, not showing in the console.So I didn't use Alignment="Right" and FormatString.dir.ps1:# sp81 has 81 spaces.$sp81 = ' '$a = Get-ChildItem -Path $args[0]ForEach $b in $a{ $width = 80 If $b.Attributes -Like '*Directory*' { $c1 = $b.FullName + '\' } Else { $c1 = $b.FullName } $c2 = $c1.Length $c3 = $sp81 + $c1 $c4 = $c3.Length $c5 =

    :)
     
    noellapin, Oct 20, 2021
    #1

  2. How do I unzip many files to new respective folders?

    Powershell has an option to Compress and Expand archives.

    I would suggest writing a script in Powershell ISE (Integrated Scripting Environment) and saving the script for future calls.

    A good book to read on learning Powershell is "PowerShell in a Month of Lunches". It might seem like a drag but it is a good place to start and get a handle on the concepts of how Powershell works and how to get support from Powershell

    as a starter you could try something simple like:

    #get the list of zip files from the current directory

    $dir = dir *.zip

    #go through each zip file in the directory variable

    foreach($item in $dir)

    {

    Expand-Archive -Path $item -DestinationPath ($item -replace '.zip','') -Force

    }
     
    pestell159, Oct 20, 2021
    #2
  3. Bentley12 Win User
    Batch File to list files from two seperat networks

    Hello,

    I work in a factory where multiple PCs are on seperate VLANs. I need to view contents of a directory from one VLAN called "Admin" and compare it with individual directories from multiple PCs on another VLAN called "Shop" ("Shop" is not part of the Domain)

    I have created a VB script that will compare two txt files and report the diffences. So I am trying to create two text files from each VLAN using a batch file. The batch file will be ran from a PC with two network cards so it can see both VLANs.

    I can easily create the list from the "Admin" network using:
    dir /b \\Server\Share\ > Active.txt

    The "Shop" list is different. It needs a username and password. All Shop PCs have the same user name and password but I'm not sure how to structure the script to create a list from multiple PCs using a user name and password.
    If I open the folders from Windows and enter the credentials then a script like this will work:
    dir /b \\PC_Name1\Share > Programs.txt
    dir /b \\PC_Name2\Share >> Programs.txt

    Using the command above without first opening the folder and entering the credentials gives this error: Logon failure: unknown user name or bad password

    Thanks in advance for any help.
     
    Bentley12, Oct 20, 2021
    #3
  4. "dir" like PowerShell script for wrting to a text file

    Powershell command file to automatically list file/folder names

    I used "dir /b > file.txt" in a shift+right-click command prompt window to get the result I needed. Now, shift+right-click only shows the option for Powershell. I don't necessarily want to edit the registry to change that so I'm trying to adapt. In Powershell, using the command "ls | % Name file.txt" does the trick but there's two things I want to be able to do...

    1) Double-click a single command file to run the script and automatically generate the text file I need
    2) Have the script ignore the "file.txt" and the command file itself (because it adds "file.txt" to the list, which I don't need)

    I have tried making a .ps1 file but my knowledge is very limited on using Powershell and I can't get it work exactly how I need. I don't need anything from the list other than the file/folder name itself (no properties such as size, type, etc.) Any help would be appreciated.

    Thanks!
     
    ReleaseTheKrkn, Oct 20, 2021
    #4
Thema:

"dir" like PowerShell script for wrting to a text file

Loading...
  1. "dir" like PowerShell script for wrting to a text file - Similar Threads - dir PowerShell script

  2. sudo dir not working powershell

    in Windows 10 Gaming
    sudo dir not working powershell: in powershell when i type sudo dir its says command not found. but when i type only dir it worksdir with no sudo in front in powershell worksbut sudo dir in cmd works finefrom what i know dir is not a cmdlet of powershell...
  3. sudo dir not working powershell

    in Windows 10 Software and Apps
    sudo dir not working powershell: in powershell when i type sudo dir its says command not found. but when i type only dir it worksdir with no sudo in front in powershell worksbut sudo dir in cmd works finefrom what i know dir is not a cmdlet of powershell...
  4. "dir" like PowerShell script for wrting to a text file

    in Windows 10 Network and Sharing
    "dir" like PowerShell script for wrting to a text file: I think I must have re-re-invented a wheel, but I couldn't find such a script.I hope this will help someone lacking the search skill it's me .This is for writing to a text file, not showing in the console.So I didn't use Alignment="Right" and FormatString.dir.ps1:# sp81 has...
  5. "dir" like PowerShell script for wrting to a text file

    in Windows 10 Software and Apps
    "dir" like PowerShell script for wrting to a text file: I think I must have re-re-invented a wheel, but I couldn't find such a script.I hope this will help someone lacking the search skill it's me .This is for writing to a text file, not showing in the console.So I didn't use Alignment="Right" and FormatString.dir.ps1:# sp81 has...
  6. PowerShell script

    in Windows 10 Support
    PowerShell script: The code below tests a series of IPs in a txt file.The result is as follows and is written in a txt file. 19.191.12.161 - online 19.191.12.162 - offline 19.191.12.163 - offline 19.191.12.164 - offline 19.191.12.165 - offline also see the scrennshot Code: $Output= @()$GetIP =...
  7. Hashing in powershell, output to a text file.

    in Windows 10 Support
    Hashing in powershell, output to a text file.: I want to hash file with sha512 and output it to txt file, as it doesn't show in powershell, because it is too long! So code is like this. Code: get-filehash "D:\files\OS\Linux\Debian\debian-10.5.0-amd64-netinst.iso" -Algorithm SHA512 c:\test.txt It gives error code like...
  8. powershell scripts

    in AntiVirus, Firewalls and System Security
    powershell scripts: Hi, I have azure. Someone is somehow installing powershell scripts onto my computer that allows them to host my PC through P2P and UDP connections, well I think so anyway. I have only just found powershell script entry changes in my registry by accident. These criminals...
  9. powershell script

    in Windows 10 Customization
    powershell script: looking for a script to monitor for a folder, if there is a file in that folder send it as an email, once the email is sent out, confirm and then move the files to an archive folder. monitor c:\test\*.pdf No files, do not send email. Yes Files, send an email to someone at...
  10. Running PowerShell script as a batch file

    in Windows 10 Network and Sharing
    Running PowerShell script as a batch file: Can I run the Power Shell line: "C:\Windows\System32>get-appxpackage *3dbuilder* | remove-appxpackage" from a .Bat file? ***Original title: Removing bloatware***...