0

Summary:

I have approximately 30 users. I am looking for a simple way to update and manage these users powershell scripts without forcing them to download or run commands to update. I have an implicit remoting server, however, I cannot run certain scripts from it due to certain limitations. For example, one script relies on finding a specific certificate in the users cert store and enumerating that value to access a web application. This cannot be done via implicit remoting because the users cert store doesn't exist on the remote server.

Question:

Is there an easy way to manage users powershell scripts without forcing them to make updates?

  • 1
    What do you mean by "manage scripts"? Do you just want a copy of all of the script files? – Cory Knutson May 3 '17 at 21:25
  • @CoryKnutson I am looking for a way to distribute the scripts to the 20 users. With out making them copy the scripts manually and import them etc. – Alexander Sinno May 3 '17 at 21:44
  • Clarifying a bit more, are the computers managed (known names, domain logins, etc)? You want users to be able to add scripts to a "Managed" directory on the local machines, and for all other users' scripts to replicate to/from other everyone else's folders. Is this correct? – Cory Knutson May 3 '17 at 21:49
  • @CoryKnutson Yes correct sorry about the ambiguity. – Alexander Sinno May 3 '17 at 21:53
2

What you are really looking for is called "Version Control", like Github or Team foundation server. They are more involved and would require the users to interact with the software. Short of that, below is a VERY rough outline of a powershell management.

This is not complete, but this would get you started. This would need some modification to fit your environment, but it would be a quick and dirty way of looking for missing or modified scripts in the users' directories. It is far from handling conflict checking, but that would be better served by a true version control product. Let me know if this is along the lines of what you are looking for.

$serverScriptPath = "C:\some\path"

$computers = "Name001","Name002","Name003"

$computers | ForEach-Object {
    $computerName = $_

    # Get Listing of user and server scripts
    $userScripts = Get-ChildItem -Path "$computerName\C$\common\script\dir"
    $serverScripts = Get-ChildItem -Path $centralScriptPath

    # Start with an empty array
    $missingScripts = @()

    # Find missing or updated scripts for user
    $missingScripts += $userScripts | Compare-Object $serverScripts -Property Name,LastWriteTime | Where-Object {$_.SideIndicator -eq "<="}

    # Pull each missing script to central location
    $missingScripts | ForEach-Object {
        Copy-Item "$computerName\C$\common\script\dir\$_" $serverScriptPath -Force
    }
}
  • Thanks Cory, I am going to give this a shot and let you know the results shortly! – Alexander Sinno May 3 '17 at 22:24
  • A couple things to keep in mind. This script will get all of the files from clients. I did not build the inverse to push the updated central store back out. It would be similar, but in reverse. You do want to pull all of the files to central first, and then push all out. – Cory Knutson May 3 '17 at 22:28
  • This is actually a really nice idea and script. Does what I need and much more. – Alexander Sinno May 3 '17 at 22:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.