ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Powershell to unhide all files and copy to nextcloud folder

    IT Discussion
    powershell bobcat nextcloud
    7
    17
    1.3k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • JaredBuschJ
      JaredBusch
      last edited by JaredBusch

      I have a customer that services Bobcat equipment.

      Bobcat sends out their service manuals on a USB in a time locked PDF. So they expire after 3 months. So annoying.

      To make it even more fun, they mark all of the files hidden and created a wrapped executable that you have to launch to search and find the files.

      Anyway, to make the documents available to all of the technicians, I have a shared folder in their Nextcloud instance. Nextcloud though, will not sync hidden files, and I do not want to globally change this behavior, if I even can. Never looked.

      So what the user was trained to do was right click the USB and uncheck the hidden checkbox.
      Then drag and drop all the files to the Nextcloud folder. The problem is this takes forever to rewrite the permissions.

      So I came up with this script. It works as is, but I am always open to any ideas for improvement.

      # Get Drive Letter
      # To Do: Make this a required parameter or pop up to user
      $DrvLtr = "D:\"
      
      # Destination path for Bobcat files This is a fixed location
      $BobcatPath = "$ENV:UserProfile\Nextcloud\Bobcat Manuals"
      
      # Let the user know we started
      Write-Host "Now removing the 'hidden' attribute from all files in the path: $DrvLtr"
      # Unhide all the things.
      Get-ChildItem -Path $DrvLtr -Recurse -Force | Where-Object {$_.Attributes -like "*hidden*"} | ForEach-Object {$_.Attributes = $_.Attributes -replace ", Hidden|Hidden,? ?", ""}
      Write-Host "All files unhidden, now copying to Nextcloud sync folder."
      
      Robocopy.exe $DrvLtr $BobcatPath /mir /R:5 /W:5 /Z
      
      Write-Host "Bobcat USB file copy complete"
      

      The only thing I thought about was adding a Write-Host in the unhide section so the user sees something happening and does not complain about nothing running.

      GreyG 1 Reply Last reply Reply Quote 0
      • gjacobseG
        gjacobse
        last edited by

        As a comfort item, I’d say the write-host would be nice. Then they know it’s working

        1 Reply Last reply Reply Quote 0
        • JaredBuschJ
          JaredBusch
          last edited by

          328b00fa-808b-4b0b-b85d-e0bf0bed002b-image.png

          DashrenderD 1 Reply Last reply Reply Quote 0
          • DashrenderD
            Dashrender @JaredBusch
            last edited by

            @JaredBusch said in Powershell to unhide all files and copy to nextcloud folder:

            328b00fa-808b-4b0b-b85d-e0bf0bed002b-image.png

            damn, that takes 41 mins to copy that? holy crap

            JaredBuschJ 1 Reply Last reply Reply Quote 0
            • JaredBuschJ
              JaredBusch @Dashrender
              last edited by

              @Dashrender said in Powershell to unhide all files and copy to nextcloud folder:

              damn, that takes 41 mins to copy that? holy crap

              That is just the robocopy time. That does not include the time unhiding the files.

              1 Reply Last reply Reply Quote 0
              • JaredBuschJ
                JaredBusch
                last edited by

                32600FFC-1BA1-4BF0-B30C-4C580F4724DC.jpeg

                DustinB3403D 1 Reply Last reply Reply Quote 0
                • DashrenderD
                  Dashrender
                  last edited by

                  35+ gigs of files - would be nice if they sprung for USB 3 drives.. and make sure the user is using a USB 3 port

                  1 Reply Last reply Reply Quote 1
                  • DustinB3403D
                    DustinB3403 @JaredBusch
                    last edited by DustinB3403

                    @JaredBusch dumb question, but if you disconnected a PC from the internet and changed the time to be prior to the expiration date of the files would you still be able to open them?

                    Fixed a typo

                    JaredBuschJ 1 Reply Last reply Reply Quote 0
                    • gjacobseG
                      gjacobse
                      last edited by

                      Addendum to my allied comment;

                      You could add the option to allow either displayed or silent processing. That way they have the option.

                      1 Reply Last reply Reply Quote 0
                      • JaredBuschJ
                        JaredBusch @DustinB3403
                        last edited by

                        @DustinB3403 said in Powershell to unhide all files and copy to nextcloud folder:

                        @JaredBusch dumb question, but if you disconnected a PC from the internet and changed the time to be prior to the expiration date of the files would you still be able to open them?

                        Probably, but it doesn't matter as there are updates that are needed. SO the files have to be updated.

                        1 Reply Last reply Reply Quote 0
                        • GreyG
                          Grey @JaredBusch
                          last edited by

                          @JaredBusch But why robocopy?

                          ObsolesceO JaredBuschJ 2 Replies Last reply Reply Quote 0
                          • ObsolesceO
                            Obsolesce @Grey
                            last edited by

                            @Grey said in Powershell to unhide all files and copy to nextcloud folder:

                            @JaredBusch But why robocopy?

                            There's no better more convenient option...

                            1 Reply Last reply Reply Quote 2
                            • JaredBuschJ
                              JaredBusch @Grey
                              last edited by

                              @Grey said in Powershell to unhide all files and copy to nextcloud folder:

                              @JaredBusch But why robocopy?

                              Because it does at least skip the ones with no changes.

                              Why get convoluted with Powershell to do the same?

                              DustinB3403D GreyG 2 Replies Last reply Reply Quote 2
                              • DustinB3403D
                                DustinB3403 @JaredBusch
                                last edited by

                                @JaredBusch I think you should install WSL with Ubuntu 16.04 to do this with bash. . .

                                1 Reply Last reply Reply Quote -1
                                • GreyG
                                  Grey @JaredBusch
                                  last edited by

                                  @JaredBusch said in Powershell to unhide all files and copy to nextcloud folder:

                                  @Grey said in Powershell to unhide all files and copy to nextcloud folder:

                                  @JaredBusch But why robocopy?

                                  Because it does at least skip the ones with no changes.

                                  Why get convoluted with Powershell to do the same?

                                  Not every system may have Robocopy.

                                  WrCombsW 1 Reply Last reply Reply Quote 0
                                  • WrCombsW
                                    WrCombs @Grey
                                    last edited by

                                    @Grey said in Powershell to unhide all files and copy to nextcloud folder:

                                    @JaredBusch said in Powershell to unhide all files and copy to nextcloud folder:

                                    @Grey said in Powershell to unhide all files and copy to nextcloud folder:

                                    @JaredBusch But why robocopy?

                                    Because it does at least skip the ones with no changes.

                                    Why get convoluted with Powershell to do the same?

                                    Not every system may have Robocopy.

                                    it became part of theOS with Windows Vista. So anything running Windows Vista or Higher will have robocopy as a part of the Operating system (as everyone should be using higher than vista at this point.. I mean.. windows 7 is obsolete now.. sooo..)

                                    DustinB3403D 1 Reply Last reply Reply Quote 0
                                    • DustinB3403D
                                      DustinB3403 @WrCombs
                                      last edited by

                                      @WrCombs said in Powershell to unhide all files and copy to nextcloud folder:

                                      @Grey said in Powershell to unhide all files and copy to nextcloud folder:

                                      @JaredBusch said in Powershell to unhide all files and copy to nextcloud folder:

                                      @Grey said in Powershell to unhide all files and copy to nextcloud folder:

                                      @JaredBusch But why robocopy?

                                      Because it does at least skip the ones with no changes.

                                      Why get convoluted with Powershell to do the same?

                                      Not every system may have Robocopy.

                                      it became part of theOS with Windows Vista. So anything running Windows Vista or Higher will have robocopy as a part of the Operating system (as everyone should be using higher than vista at this point.. I mean.. windows 7 is obsolete now.. sooo..)

                                      Windows 10 1709 is obsolete too, so really anything not with a support mechanism shouldn't be used. But @JaredBusch might be getting paid stupid amounts of money to support Windows XP / Server 2000

                                      1 Reply Last reply Reply Quote 1
                                      • 1 / 1
                                      • First post
                                        Last post