• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Snapin issue - using powershell to copy items

    Scheduled Pinned Locked Moved Unsolved
    FOG Problems
    4
    14
    625
    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.
    • D
      dellborg82 @rodluz
      last edited by dellborg82

      Hello @rodluz

      I made the changes (see below) It runs like expected when run FROM the machine; however, when running through FOG it still says running, then immediately completed, and nothing is copied. Ideas here? Log just shows completed. But the folder is empty

      cls

      $username = “starshipfrontier\wbadmin”
      $password = ConvertTo-SecureString “USSWhiteBuffalo33247” -AsPlainText -Force
      $creds = New-Object System.Management.Automation.PSCredential $username, $password
      $NetworkPath = “\starbase\Artemis_Files\Artemis Versions\Mod\Artemis 2.8 TNG Mod”
      $LocalPath = “C:\Artemis 2.8 TNG Mod”

      #New-PSDrive -Name Artemis -PSProvider FileSystem -Root “\starbase\Artemis_Files\Artemis Versions\Mod\Artemis 2.8 TNG Mod” -Credential $creds
      New-PSDrive -Name “S” -Root $NetworkPath -PSProvider “FileSystem” -Credential $cred
      #Get-PSDrive -Name “S”

      RUN YOUR CODE REFERENCING THE “Z” DRIVE

      Write-Host “Copying Artemis to Local Computer” -ForegroundColor DarkCyan

      if(Test-Path $LocalPath) {“Temp folder found”} else {New-Item -ItemType Directory -Force -Path $LocalPath}

      New-Item -ItemType Directory -Force -Path $LocalPath
      Copy-Item S:* -Destination $LocalPath -Recurse -Force

      Write-Host “Copy Complete” -ForegroundColor DarkCyan
      Remove-PSDrive -Name “S”

      Tom ElliottT 1 Reply Last reply Reply Quote 0
      • Tom ElliottT
        Tom Elliott @dellborg82
        last edited by Tom Elliott

        @dellborg82 You seem to have a typo, that or because it’s not in code format (triple back ticks) we’re losing context.

        Your script should be:

        $NetworkPath = "\\starbase\Artemis_Files\Artemis Versions\Mod\Artemis 2.8 TNG Mod"
        $LocalPath = "C:\Artemis 2.8 TNG Mod"

        $username = "starshipfrontier\wbadmin"
        $password = ConvertTo-SecureString "USSWhiteBuffalo33247" -AsPlainText -Force
        $creds = New-Object System.Management.Automation.PSCredential $username, $password

        New-PSDrive -Name "S" -Root $NetworkPath -PSProvider "FileSystem" -Credential $cred

        If (-Not (Test-Path $LocalPath)) {
        Write-Host "Creating $LocalPath" -ForegroundColor DarkCyan
        New-Item -ItemType Directory -Force $LocalPath
        }

        Write-Host "Copying Artemis to Local Computer" -ForegroundColor DarkCyan
        Copy-Item S:\* -Destination $LocalPath -Recurse -Force

        Write-Host "Copy Complete" -ForegroundColor DarkCyan
        Remove-PSDrive -Name "S"

        Why it’s not showing the full appropriately lined strings I don’t know.

        7f42e8ea-4bbc-4b6c-a8a0-a744774348ff-image.png

        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

        Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

        Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

        D 1 Reply Last reply Reply Quote 0
        • D
          dellborg82 @Tom Elliott
          last edited by

          Hello @Tom-Elliott, Thanks for your help here; however, it’s still not working and when I run it locally, I get the below error on New-PSDrive

          fe8924d7-ffa1-4fbb-8f0e-a8ac2c603152-image.png

          I’m not the best at PowerShell, but have been learning here and there.

          Please Advise where this may be going wrong. Unless I’m Mistaken (and I likely am) is this being caused by the $credIf (-Not (Test-Path $LocalPath)) part of the script?

          Tom ElliottT 1 Reply Last reply Reply Quote 0
          • Tom ElliottT
            Tom Elliott @dellborg82
            last edited by

            @dellborg82 I printed the actual code as an image in my post because for some reason the code syntax is joining lines in appropriately here.

            Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

            Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

            Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

            D 1 Reply Last reply Reply Quote 0
            • D
              dellborg82 @Tom Elliott
              last edited by

              @Tom-Elliott Thanks for clarifying that.

              I’m not sure why I didn’t catch that. Trying now. (It ran locally, just fine); however, run run via FOG, The pop up comes up that says it’s running, 3 seconds later, popup shows it’s complete (this is what we’ve been seeing)

              I check the folder… empty

              Tom ElliottT 1 Reply Last reply Reply Quote 0
              • Tom ElliottT
                Tom Elliott @dellborg82
                last edited by

                @dellborg82 Can you look at the event logs and see if anything shows up for that timeframe that the script actually runs.

                Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                D 1 Reply Last reply Reply Quote 0
                • D
                  dellborg82 @Tom Elliott
                  last edited by

                  @Tom-Elliott Here’s the log file from C:\fog.txt. As far as I can tell, (again I could be wrong) but it looks like the log shows it’s running.


                  8/16/2023 5:14:14 PM Client-Info Client Version: 0.13.0
                  8/16/2023 5:14:14 PM Client-Info Client OS: Windows
                  8/16/2023 5:14:14 PM Client-Info Server Version: 1.5.10.10
                  8/16/2023 5:14:14 PM Middleware::Response Success
                  8/16/2023 5:14:14 PM SnapinClient Running snapin Copy Current Artemis
                  8/16/2023 5:14:14 PM Middleware::Communication Download: https://10.4.47.15/fog/service/snapins.file.php?mac=5C:51:4F:AB:0E:92|5E:51:4F:AB:0E:91|18:A9:9B:FD:A2:71|5C:51:4F:AB:0E:91|5C:51:4F:AB:0E:95&taskid=178
                  8/16/2023 5:14:15 PM SnapinClient C:\Program Files (x86)\FOG\tmp\Copy_Current_Artemis_V3.ps1
                  8/16/2023 5:14:15 PM Bus Emmiting message on channel: Notification
                  8/16/2023 5:14:15 PM SnapinClient Starting snapin
                  8/16/2023 5:14:18 PM SnapinClient Snapin finished
                  8/16/2023 5:14:18 PM SnapinClient Return Code: 0
                  8/16/2023 5:14:18 PM Bus Emmiting message on channel: Notification
                  8/16/2023 5:14:18 PM Middleware::Communication URL: https://10.4.47.15/fog/service/snapins.checkin.php?taskid=178&exitcode=0&mac=5C:51:4F:AB:0E:92|5E:51:4F:AB:0E:91|18:A9:9B:FD:A2:71|5C:51:4F:AB:0E:91|5C:51:4F:AB:0E:95&newService&json

                  But still nothing in the C:\Artemis 2.8 TNG Mod Directory. The directory gets created, but it’s empty.

                  D 1 Reply Last reply Reply Quote 0
                  • D
                    dellborg82 @dellborg82
                    last edited by

                    @Tom-Elliott

                    Is this what you were looking for?

                    D 1 Reply Last reply Reply Quote 0
                    • D
                      dellborg82 @dellborg82
                      last edited by

                      @dellborg82 @Tom-Elliott Thanks for your help here, I was able to figure out the issue with your guidance. I’m not 5/5 on successful copies via PowerShell.

                      Tom ElliottT 1 Reply Last reply Reply Quote 0
                      • Tom ElliottT
                        Tom Elliott @dellborg82
                        last edited by

                        @dellborg82 What was the issue? This way somebody else who may be having a similar issue can also be helped?

                        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                        Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                        Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

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

                        199

                        Online

                        12.1k

                        Users

                        17.3k

                        Topics

                        155.3k

                        Posts
                        Copyright © 2012-2024 FOG Project