Skip to content

Latest commit

 

History

History
118 lines (108 loc) · 6.21 KB

2. HOW TO USE - EXAMPLES.md

File metadata and controls

118 lines (108 loc) · 6.21 KB

HOW TO USE - EXAMPLES


  • everything in italics refers to content of your locally cloned GIT CI/CD repository

  • every example bellow should be of course ended with commiting the change :)

  • in case these examples didn't answer your questions, you can check FAQ


LINKS TO VIDEO SHOWING HOW TO USE DIFFERENT FEATURE OF THIS REPOSITORY


WRITTEN EXAMPLES

  • Receive newest repository content + import new data to running Powershell console

    • just run function "Refresh-Console" (stored in adminFunctions module)
      • function will initialize update of DFS repository content, than download of this data to your computer and "refresh" running console from which ref was invoked, so you can immediately work with this new data (variables, functions, modules, PATH, ..) without need to open new console
      • supports also refresh of remote computer
  • Distribute Powershell module to all clients

    • place the module folder to Modules
  • Distribute Powershell module "Posh-SSH" to just computers "PC-1" and "PC-2"

    • place the module "Posh-SSH" to Modules
    • edit modulesConfig.ps1 as follows
    $modulesConfig = @(
      [PSCustomObject]@{
          folderName   = "Posh-SSH" # name of module
          computerName = "PC-1", "PC-2" # name of computer/s (variable from module Variables could be used too)
      }
  • Create new Powershell function Get-CurrentLoad and distribute it to all clients

    • in scripts2module\Scripts create file Get-CurrentLoad.ps1 with identically named function
    • after commit, this will lead to creation of Scripts module, that will contains all functions defined in ps1 scripts in Scripts folder and will be distributed on all clients
    • if you want to export function to different module, just create new folder in scripts2module and place ps1 files with functions in it
  • Create new Powershell function Repair-OutlookProfile and distribute it to just chosen clients

    • in scripts2module create new folder SomeNewModule. Inside it create file Repair-OutlookProfile.ps1 with identically named function
    • after commit, this will lead to creation of module SomeNewModule (so choose name of folder carefuly), that will contains all functions defined in ps1 scripts in SomeNewModule folder
    • edit modulesConfig.ps1 as follows
    $modulesConfig = @(
      [PSCustomObject]@{
          folderName   = "SomeNewModule" # name of module
          computerName = "PC-1", "PC-2" # name of computer/s (variable from module Variables could be used too)
      }
  • Distribute folder "Monitoring_Scripts" (with whatever content, for example Powershell script and helper files (PS modules etc)) to computer "SERVER-10" (to default location ie C:\Windows\Scripts)

    • place for example folder Monitoring_Scripts to Custom
    • edit customConfig.ps1 as follows
    $customConfig = @(
      [PSCustomObject]@{
          folderName            = "Monitoring_Scripts"
          computerName          = "SERVER-10"
          customDestinationNTFS = "svc-o365" # if just this account should have read permissions to local folder copy on SERVER-10
      }
    }
  • Distribute just content of folder "IIS_Config" just to web servers to C:\WWWroot

    • place for example folder IIS_Config to Custom
    • edit customConfig.ps1 as follows
    $customConfig = @(
      [PSCustomObject]@{
          folderName            = "IIS_Config"
          computerName          = $webServer # variable is defined in Variables module
          copyJustContent       = 1
          customLocalDestination = "C:\WWWroot"
      }
    }
  • Distribute folder "Photo_sync" to share "\\DOMAIN\DFS\root\scripts" and limit who can access to it

    • place for example folder Photo_sync to Custom
    • edit customConfig.ps1 as follows
    $customConfig = @(
      [PSCustomObject]@{
          folderName            = "Photo_sync"
          customShareDestination = "\\DOMAIN\DFS\root\scripts"
          customDestinationNTFS   = "APP-1$", "APP-2$", "domain admins" # who will have READ right on this folder
      }
    }
  • Auto creation of Scheduled Task/s from XML definition

    • steps are the same as for any other distribution of content to just custom computers, so:
    • place for example folder AD_monitoring to Custom
      • this folder should contains
        • DomainAdmins_check.xml
          • it must be in root of folder and named the same way as the value of key 'scheduledTask' in $customConfig
          • it must contain exported scheduled task definition (from which will be created sch. task on destination server)
        • some scripts, which will be used by created scheduled task etc
          • on destination computer they will be placed to C:\Windows\Scripts\AD_monitoring, so take it in to consideration when defining the scheduled task!
    • edit customConfig.ps1 as follows
    $customConfig = @(
      [PSCustomObject]@{
          folderName            = "AD_monitoring"
          computerName          = "name_of_monitoring_server"
          scheduledTask         = "DomainAdmins_check" 
      }
    }

    this will lead to distribute content of "AD_monitoring" folder to computer "name_of_monitoring_server" and creation of scheduled task named "DomainAdmins_check" from "DomainAdmins_check.xml" definition.

    • how to get XML representation of scheduled task?
      • in Task Scheduler console create task, exactly same as should be on destination computer
      • right click on that task and choose 'Export...'