Brian P Posted September 6, 2018 Report post Posted September 6, 2018 Hello friends. I'm trying to create a script can be activated from ConfigMgr consol that will copy some folders and files to all users who been logged on the computer. The script is working fine if I'm running it manually from Powershell. If running the from ConfigMgr consol the "Script" function execute and complete but nothing happens. Just for testing I tried to add the lines below, then the console just keep saying creating job. I can see it copies the script to the target computer in the ScriptStore. ### Only for testing ### Add-Type -AssemblyName PresentationCore,PresentationFramework $ButtonType = [System.Windows.MessageBoxButton]::OK $MessageIcon = [System.Windows.MessageBoxImage]::Information $MessageBody = "CUE Prod Installed!" $MessageTitle = "Install Status" $Result = [System.Windows.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon) Add-Type -AssemblyName PresentationCore,PresentationFramework $UserFolder = Get-ChildItem -path "C:\Users\*" #$Folders = Get-ChildItem -Path $PSScriptRoot -Exclude "CUEPrint.lnk", "Install-CUEPrintProd.ps1", "Install-CUEPrintProdAllUsers.ps1" #$SourceLink = Get-Item -Path ($PSScriptRoot + "\CUEPrint.lnk") $Folders = Get-ChildItem -Path "\\XXX\s$\Powershell\Newsgate\Prod" -Exclude "CUEPrint.lnk", "Install-CUEPrintProd.ps1", "Install-CUEPrintProdAllUsers.ps1" $SourceLink = Get-Item -Path ("\\XXX\s$\Powershell\Newsgate\Prod" + "\CUEPrint.lnk") foreach ($file in $UserFolder) { Copy-Item $Folders -Destination $file'\Appdata\local' Copy-Item $SourceLink -Destination $file'\Desktop\' } Copy-Item $Folders -Destination 'C:\Users\Default\appdata\Local' Copy-Item $SourceLink -Destination 'C:\Users\Default\Desktop' ### Only for testing ### $ButtonType = [System.Windows.MessageBoxButton]::OK $MessageIcon = [System.Windows.MessageBoxImage]::Information $MessageBody = "CUE Prod Installed!" $MessageTitle = "Install Status" $Result = [System.Windows.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon) #Write-Host "Your choice is $Result" Quote Share this post Link to post Share on other sites More sharing options...
Brian P Posted September 6, 2018 Report post Posted September 6, 2018 I found out it was permissions on the share, can anyone enlighten me, what user is "Run Script" using when running? $UserFolder = Get-ChildItem -path "C:\Users\*" $Folders = Get-ChildItem -Path "\\XXX\s$\Powershell\Newsgate\Prod" -Exclude "CUEPrint.lnk", "Install-CUEPrintProd.ps1", "Install-CUEPrintProdAllUsers.ps1" $SourceLink = Get-Item -Path ("\\XXX\s$\Powershell\Newsgate\Prod" + "\CUEPrint.lnk") foreach ($file in $UserFolder) { Copy-Item $Folders -Destination $file'\Appdata\local' Copy-Item $SourceLink -Destination $file'\Desktop\' } Copy-Item $Folders -Destination 'C:\Users\Default\appdata\Local' Copy-Item $SourceLink -Destination 'C:\Users\Default\Desktop' Quote Share this post Link to post Share on other sites More sharing options...
skissinger Posted September 6, 2018 Report post Posted September 6, 2018 My guess--and it's just a guess. I'm assuming that since it's the client that picked up the script to run, it'll be similar to the same context that other scripts run in, when picked up by policies, like Configuration Item Scripts, or Scripts used for Detection Logic for Applications--which is NT Authority\System, of the individual device. So if you want all your Domain Computers to have rights to some remote share, you'll want to make a share, and grant (I think) "Domain Authenticated Users" both NTFS modify to that location, and that the Share also has Modify rights to Authenticated Users. I think that might work... I see you're trying to use s$... that would be an Admin share. I wouldn't use that. Make a real Share, which you can permission properly. 1 Quote Share this post Link to post Share on other sites More sharing options...
Brian P Posted September 28, 2018 Report post Posted September 28, 2018 Hi again. @skissinger it did work when checking up with the shares, thank you! My script is not working, but I'm really not happy with it, I think its a big mess. Is there a predefined function/$env:xxx for all users desktop or a smarter way to gather the variables below to? $profilesfolder = 'c:\users\' $excluded_profiles = @( 'All Users', 'Default.migrated', 'Public' ) $profiles = get-childitem $profilesfolder -Directory -force | Where-Object { $_.BaseName -notin $excluded_profiles } $targetfolder = '\AppData\Local\' $Desktop = '\Desktop\' $destination = $profilesfolder + $profile + $targetfolder (C:\Users\user1\AppData\Local, C:\Users\user2\AppData\Local, etc.) $CUELinkDestination = $profilesfolder + $profile + $Desktop (C:\Users\user1\Desktop, C:\Users\user2\Desktop, etc.) # Set source files for CUE Print Installation $sourcefolder = Get-Item -path "\\NETWORKSHARE\Software\CCI\Prod\CCI Europe", "\\dc1\NETLOGON\Software\CCI\Prod\CUEPrint" $CUELink = Get-Item -Path "\\NETWORKSHARE\Software\CCI\Prod\CUEPrint.lnk" $profilesfolder = 'c:\users\' $excluded_profiles = @( 'All Users', 'Default.migrated', 'Public' ) $profiles = get-childitem $profilesfolder -Directory -force | Where-Object { $_.BaseName -notin $excluded_profiles } $targetfolder = '\AppData\Local\' $Desktop = '\Desktop\' $logfile = "\\NETWORKSHARE\Software\CCI\logs\$env:COMPUTERNAME.log" $FormattedDate = Get-Date -Format "yyyy-MM-dd HH:mm:ss" # Copying files to Desktop and LocalApp foreach ($profile in $profiles) { $destination = $profilesfolder + $profile + $targetfolder $CUELinkDestination = $profilesfolder + $profile + $Desktop Write-Output "$FormattedDate : Starting to copy CUEPrint Prod for $profile" | Out-File -FilePath $logfile -Append Copy-Item -Path $sourcefolder -Destination $Destination -Force -Recurse Copy-Item -Path $CUELink -Destination $CUELinkDestination -Force Write-Output "$FormattedDate : Files copied to user: $profile" | Out-File -FilePath $logfile -Append } # Looking for Microsoft Visual C++ 2005 x86 If (Get-Item -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{710f4c1c-cc18-4c49-8cbf-51240c89a1a2}" -ErrorAction SilentlyContinue) { # Application exists Write-Output 'Microsoft Visual C++ 2005 x86 already Installed!' } Else { #Installing Applications Write-Output "$FormattedDate : Installing Microsoft Visual C++ 2005 x86.." | Out-File -FilePath $logfile -Append Start-Process '\\NETWORKSHARE\Software\CCI\C++\Microsoft Visual C++ 2005 x86.exe' /q -NoNewWindow -Wait | Out-Null Write-Output "$FormattedDate : Installation completed." | Out-File -FilePath $logfile -Append } # Looking for Microsoft Visual C++ 2010 x86 If (Get-Item -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{F0C3E5D1-1ADE-321E-8167-68EF0DE699A5}" -ErrorAction SilentlyContinue) { # Application exists Write-Output 'Microsoft Visual C++ 2010 x86 already installed!' } Else { #Installing Applications Write-Output "$FormattedDate : Installing Microsoft Visual C++ 2010 x86.." | Out-File -FilePath $logfile -Append Start-Process '\\NETWORKSHARE\Software\CCI\C++\Microsoft Visual C++ 2010 x86.exe' /q -NoNewWindow -Wait| Out-Null Write-Output "$FormattedDate : Installation completed." | Out-File -FilePath $logfile -Append } # Looking for Microsoft Visual C++ 2015 x86 If (Get-Item -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{e2803110-78b3-4664-a479-3611a381656a}" -ErrorAction SilentlyContinue) { # Application exists Write-Output 'Microsoft Visual C++ 2005 x86 already installed"' } Else { #Installing Applications Write-Output "$FormattedDate : Installing Microsoft Visual C++ 2015 x86.." | Out-File -FilePath $logfile -Append Start-Process '\\NETWORKSHARE\Software\CCI\C++\Microsoft Visual C++ 2015 x86.exe' /quiet -NoNewWindow -Wait| Out-Null Write-Output "$FormattedDate : Installation completed." | Out-File -FilePath $logfile -Append } Quote Share this post Link to post Share on other sites More sharing options...
skissinger Posted October 2, 2018 Report post Posted October 2, 2018 maybe I'm speaking out of turn here... but I am completely lost as to why you are trying to use a script to install software from a network share. Why wouldn't you create applications, to install Visual C++ 2005, and another one for 2015... etc? i.e., use CM like it's supposed to be used? the scripts node to me doesn't make sense as a way to do this. Quote Share this post Link to post Share on other sites More sharing options...
Brian P Posted October 3, 2018 Report post Posted October 3, 2018 9 hours ago, skissinger said: maybe I'm speaking out of turn here... but I am completely lost as to why you are trying to use a script to install software from a network share. Why wouldn't you create applications, to install Visual C++ 2005, and another one for 2015... etc? i.e., use CM like it's supposed to be used? the scripts node to me doesn't make sense as a way to do this. The software vendor provided us with an executable that have to be installed as current user, it copies files to there LocalApp folder and desktop and the installer requires C++ 2005, 2010 and 2015 or higher. We have a mixed environment with Windows 7 with all versions of C++ and Windows 10 with C++ 2010 and above. Maybe we were to optimistic, but we didn't think that our new versions of software still required C++ 2005 so we did not include it in our Windows 10 images and may have to rethink that part. We don't want to install more software then needed on our machines and our user are using more then one machine depending on that task there a supposed to do. For that reason I created the script to make sure that we can provide the users with the software if they contact us about missing software. Quote Share this post Link to post Share on other sites More sharing options...