Skip to content

Latest commit

 

History

History
88 lines (80 loc) · 6.03 KB

3. SIMPLIFIED EXPLANATION OF HOW IT WORKS.md

File metadata and controls

88 lines (80 loc) · 6.03 KB

Explanation of repository content, it's purpose and automation behind it

Important content of the repository and it's purpose

<<your cloned repository root>>
│   !!!README!!!.txt                -- initial instructions for automation configuration
│   .gitignore
│   powershell.json                 -- Powershell snippets used in Visual Studio Code
│   PSScriptAnalyzerSettings.psd1   -- configuration file for Invoke-ScriptAnalyzer command called in pre-commit.ps1 
│                                     (compatibility, syntax etc checks)
│
├───.githooks                       -- scripts used for GIT automation
│       commit-msg
│       commit-msg.ps1                  -- check format of commit message
│       post-commit
│       post-commit.ps1                 -- automatically push commit to remote repository
│       post-merge
│       post-merge.ps1
│       pre-commit
│       pre-commit.ps1                  -- automatically checks commited files against rules defined inside
│
├───.vscode                         -- config files for Visual Studio Code editor
│       extensions.json                 -- addons recommendations
│       launch.json
│       settings.json                   -- how should editor behave, look, format code etc
│
├───custom                          -- contains content which should be copied just to selected computers|shares
|   │   customConfig.ps1                -- contains $customConfig variable, that is used to define what should be done with custom folder content
│   │
│   └───Repo_sync                   -- should be deployed to MGM server 
│           login.xml                   -- credentials of git puller account
│           repo_sync.ps1               -- **repository shared folder synchronization script** (pulls data from remote repository, processes them (generates PowerShell module 
|                                          from scripts2module etc) and distributes (clients part) to shared folder
│           repo_sync.xml               -- xml definition of repo_sync scheduled tasks, that runs repo_sync.ps1 regularly
│
├───modules                         -- contains PowerShell modules which will be copied to C:\Windows\System32\WindowsPowerShell\v1.0\Modules on clients
│   │   modulesConfig.ps1               -- contains $modulesConfig variable, that is used to define to which computers should be copied which modules (even from scripts2module)
│   │
│   ├───PSScriptAnalyzer                -- PowerShell module used for pre-commit checks
│   │
│   ├───adminFunctions                  -- PowerShell module (contains Refresh-Console function) that will be available on same computers as the ones with global PowerShell 
│   │                                      profile (i.e. defined by variable $_computerWithProfile)                                    
│   └───Variables                       -- PowerShell module with "global" variables, because it is distributed on every client
│
├───scripts2module                  -- from content of subfolders are automatically generated Powershell modules on MGM server
│   └───scripts                         -- from ps1 scripts in this folder will be generated Powershell module Scripts
│   │
│   └───adminFunctions                  -- from ps1 scripts in this folder will be generated Powershell module adminFunctions
│
└───scripts2root                    -- files in root of this folder will be copied to root of shared folder
    └───PS_env_set_up.ps1               -- **client synchronization script** (downloads content from shared folder, sets NTFS permissions, creates sched. task, deletes obsolete     │                                           content)
    └───profile.ps1                 -- PowerShell profile, that will be copied to C:\Windows\System32\WindowsPowerShell\v1.0 (i.e. will be global PowerShell profile) on                                                computers in variable $_computerWithProfile (defined in Variables module)
                                        -- contains many usefull features such as customized consoel title, that shows number of commits, this console is behind your computer                                              state etc

How code validation works

  • after you commit your changes, pre-commit git hook automatically initiate checks defined in pre-commit.ps1
  • only if all checks are passed, commit will be created and content distributed
    • checks can stop creation of commit completely, or warn you about possible problems and let you decide, whether to continue

What is validated before commit is created

  • that you are not trying to delete important repository files
  • that Powershell files
    • are encoded as UTF-8 or UTF-8 with BOM
    • have valid syntax
    • doesn't contain EN DASH, EM DASH instead of dash (it would lead to strange errors)
    • doesn't contain #FIXME comment, otherwise warn about it
    • from which modules are generated are in correct form
  • warn about changed function parameters (in case, the functions is used elsewhere)
  • warn about changed function aliases (in case, the alias is used elsewhere)
  • warn about deleted function (in case, the function is used elsewhere)
  • warn about changed variable value from module Variables (in case, the variable is used elsewhere)
  • warn about deleted variable from module Variables (in case, the variable is used elsewhere)
  • ...

How distribution of content works

  • after successful commit, content is automatically:
    • pushed to GIT repository
      • by post-commit GIT hook (post-commit.ps1)
    • pulled to local server, processed and (clients part) distributed to shared folder
      • by repo_sync.ps1 which is regularly run every 15 minutes by scheduled task
    • from shared folder the content is being downloaded by clients in your Active Directory
      • by PS_env_set_up.ps1 which is regularly run on client every 30 minutes by automatically created scheduled task (created via GPO PS_env_set_up)

TODO