Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
joeltimothyoh committed Nov 20, 2019
2 parents 5833f82 + 85b15e9 commit c2f6154
Show file tree
Hide file tree
Showing 18 changed files with 1,083 additions and 67 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "build/PSModulePublisher"]
path = build/PSModulePublisher
url = https://github.com/theohbrothers/PSModulePublisher.git
[submodule "build/PSRepositoryReleaseManager"]
path = build/PSRepositoryReleaseManager
url = https://github.com/theohbrothers/PSRepositoryReleaseManager.git
174 changes: 164 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,179 @@
# ScheduledTaskManagement

[![badge-build-azuredevops-build-img][]][badge-build-azuredevops-build-src] [![badge-version-github-release-img][]][badge-version-github-release-src] [![badge-version-powershellgallery-releases-img][]][badge-version-powershellgallery-releases-src]

[badge-build-azuredevops-build-img]: https://img.shields.io/azure-devops/build/theohbrothers/ScheduledTaskManagement/8/master.svg?label=build&logo=azure-pipelines&style=flat-square
[badge-build-azuredevops-build-src]: https://dev.azure.com/theohbrothers/ScheduledTaskManagement/_build?definitionId=8
[badge-version-github-release-img]: https://img.shields.io/github/v/release/theohbrothers/ScheduledTaskManagement?style=flat-square
[badge-version-github-release-src]: https://github.com/theohbrothers/ScheduledTaskManagement/releases
[badge-version-powershellgallery-releases-img]: https://img.shields.io/powershellgallery/v/ScheduledTaskManagement?logo=powershell&logoColor=white&label=PSGallery&labelColor=&style=flat-square
[badge-version-powershellgallery-releases-src]: https://www.powershellgallery.com/packages/ScheduledTaskManagement/

## Introduction

A PowerShell module for non-interactive management of Scheduled Tasks.

## Requirements

* **Windows** with [PowerShell](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-windows-powershell).

## Installation

First, ensure [`PSGallery`](https://www.powershellgallery.com/) is registered as a PowerShell repository:

```powershell
Import-Module .\src\ScheduledTaskManagement\ScheduledTaskManagement.psm1 -Force -Verbose
Register-PSRepository -Default -Verbose
```

To install the module:

# .ps1 definition file
```powershell
# Latest, for the current user
Install-Module -Name ScheduledTaskManagement -Repository PSGallery -Scope CurrentUser -Verbose
# Specific version, for the current user
Install-Module -Name ScheduledTaskManagement -Repository PSGallery -RequiredVersion x.x.x -Scope CurrentUser -Verbose
# Latest, for all users
Install-Module -Name ScheduledTaskManagement -Repository PSGallery -Scope AllUsers -Verbose
```

## Usage

### Scheduled tasks

To create scheduled tasks, first define the properties of each task in `.ps1` or `.json` definition file(s). Then feed each definition file path, directory path, or definition array objects to `Setup-ScheduledTask` to create them non-interactively.

The properties of each task definition object are based off the following cmdlets from the [`ScheduledTasks`](https://docs.microsoft.com/en-us/powershell/module/scheduledtasks) module, making them customizable and extensible:

```powershell
New-ScheduledTaskTrigger
New-ScheduledTaskAction
New-ScheduledTaskSettingsSet
New-ScheduledTaskPrincipal
```

Sample defintion files can be found [here](docs/samples/definitions/scheduledtasks).

### Functions

#### Parameters

```powershell
Setup-ScheduledTask -DefinitionFile <string[]> [-AsJson] [<CommonParameters>]
Setup-ScheduledTask -DefinitionDirectory <string[]> [-AsJson] [<CommonParameters>]
Setup-ScheduledTask -DefinitionObject <Object[]> [<CommonParameters>]
```

#### Examples

```powershell
# Via .ps1 definition file
Setup-ScheduledTask -DefinitionFile "C:\path\to\definition.ps1"
# .json definition file
# Via .json definition file
Setup-ScheduledTask -DefinitionFile "C:\path\to\definition.json" -AsJson
# Directory containing .ps1 definition files
# Via directory containing .ps1 definition files
Setup-ScheduledTask -DefinitionDirectory "C:\path\to\definition\directory\"
# Directory containing .json definition files
# Via directory containing .json definition files
Setup-ScheduledTask -DefinitionDirectory "C:\path\to\definition\directory\" -AsJson
# Definition objects
Setup-ScheduledTask -DefinitionObject $objects
# Via definition objects
$tasks = . "C:\path\to\definition.ps1"
Setup-ScheduledTask -DefinitionObject $tasks
```

## Tips
To list all available functions of the module:

```powershell
Get-Command -Module ScheduledTaskManagement
```

## Administration

### Versions

To list versions of the module on `PSGallery`:

```powershell
# Latest
Find-Module -Name ScheduledTaskManagement -Repository PSGallery -Verbose
# All versions
Find-Module -Name ScheduledTaskManagement -Repository PSGallery -AllVersions -Verbose
```

- `-DefinitionFile`, `-DefinitionDirectory`, and `-DefinitionObject` accept an array of objects.
- You can use the `-Verbose` for verbose output.
To update the module (**Existing versions are left intact**):

```powershell
# Latest
Update-Module -Name ScheduledTaskManagement -Verbose
# Specific version
Update-Module -Name ScheduledTaskManagement -RequiredVersion x.x.x -Verbose
```

To uninstall the module:

```powershell
# Latest
Uninstall-Module -Name ScheduledTaskManagement -Verbose
# All versions
Uninstall-Module -Name ScheduledTaskManagement -AllVersions -Verbose
# To uninstall all other versions other than x.x.x
Get-Module -Name ScheduledTaskManagement -ListAvailable | ? { $_.Version -ne 'x.x.x' } | % { Uninstall-Module -Name $_.Name -RequiredVersion $_.Version -Verbose }
# Tip: Simulate uninstalls with -WhatIf
```

### Repositories

To get all registered PowerShell repositories:

```powershell
Get-PSRepository -Verbose
```

To set the installation policy for the `PSGallery` repository:

```powershell
# PSGallery (trusted)
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted -Verbose
# PSGallery (untrusted)
Set-PSRepository -Name PSGallery -InstallationPolicy Untrusted -Verbose
```

### Development

To import / re-import the module:

```powershell
# Installed version
Import-Module -Name ScheduledTaskManagement -Force -Verbose
# Project version
Import-Module .\src\ScheduledTaskManagement\ScheduledTaskManagement.psm1 -Force -Verbose
```

To remove imported functions of the module:

```powershell
Remove-Module -Name ScheduledTaskManagement -Verbose
```

To list imported versions of the module:

```powershell
Get-Module -Name ScheduledTaskManagement
```

To list all installed versions of the module available for import:

```powershell
Get-Module -Name ScheduledTaskManagement -ListAvailable -Verbose
```
97 changes: 97 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
trigger:
branches:
include:
- '*'
tags:
include:
- '*'
pr:
autoCancel: false
branches:
include:
- '*'

resources:
repositories:
- repository: PSModulePublisher
type: github
name: theohbrothers/PSModulePublisher
endpoint: theohbrothers # Check for your 'Type: Github' connection under 'Project Settings' > 'Service connections'
ref: refs/tags/v0.3.2
- repository: PSRepositoryReleaseManager
type: github
name: theohbrothers/PSRepositoryReleaseManager
endpoint: theohbrothers
ref: refs/tags/v0.5.2

stages:
- stage: build_test
displayName: Build, Test
jobs:
- job: windows_pwsh
displayName: '[Windows] PowerShell Core'
pool:
vmImage: windows-2019
steps:
- checkout: self
submodules: recursive
- template: templates/azure-pipelines/entrypoint/windows/continuous-build.yml@PSModulePublisher
- job: windows_powershell_5_1
displayName: '[Windows] PowerShell 5.1'
pool:
vmImage: windows-2019
steps:
- checkout: self
submodules: recursive
- template: templates/azure-pipelines/entrypoint/windows/powershell/continuous-build.yml@PSModulePublisher
- job: windows_powershell_5_0
displayName: '[Windows] PowerShell 5.0'
pool:
vmImage: vs2015-win2012r2
steps:
- checkout: self
submodules: recursive
- template: templates/azure-pipelines/entrypoint/windows/powershell/continuous-build.yml@PSModulePublisher
- job: windows_1803
displayName: '[Windows Server Core 1803] Windows PowerShell'
pool:
vmImage: win1803
steps:
- checkout: self
submodules: recursive
- template: templates/azure-pipelines/entrypoint/windows/powershell/continuous-build.yml@PSModulePublisher
- job: windows_2016
displayName: '[Windows Server 2016] Windows PowerShell'
pool:
vmImage: vs2017-win2016
steps:
- checkout: self
submodules: recursive
- template: templates/azure-pipelines/entrypoint/windows/powershell/continuous-build.yml@PSModulePublisher
- stage: publish
displayName: Publish
dependsOn: build_test
jobs:
- job: windows_powershell_5_1
displayName: '[Windows] PowerShell 5.1'
pool:
vmImage: windows-2019
steps:
- checkout: self
submodules: recursive
- template: templates/azure-pipelines/entrypoint/windows/powershell/continuous-build.yml@PSModulePublisher
- template: templates/azure-pipelines/entrypoint/windows/powershell/publish.yml@PSModulePublisher
- stage: release
displayName: Release
dependsOn: publish
jobs:
- job: linux_container
displayName: '[Linux] [Container] PowerShell Core'
pool:
vmImage: ubuntu-18.04
container: joeltimothyoh/powershell:6.1.0-ubuntu-18.04-git
steps:
- checkout: self
submodules: recursive
- template: templates/azure-pipelines/entrypoint/generate.yml@PSRepositoryReleaseManager
- template: templates/azure-pipelines/entrypoint/release.yml@PSRepositoryReleaseManager
1 change: 1 addition & 0 deletions build/PSModulePublisher
Submodule PSModulePublisher added at c91b4e
1 change: 1 addition & 0 deletions build/PSRepositoryReleaseManager
53 changes: 53 additions & 0 deletions build/definitions/modulemanifest/definition.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# - Initial setup: Fill in the GUID value. Generate one by running the command 'New-GUID'. Then fill in all relevant details.
# - Ensure all relevant details are updated prior to publishing each version of the module.
# - To simulate generation of the manifest based on this definition, run the included development entrypoint script Invoke-PSModulePublisher.ps1.
# - To publish the module, tag the associated commit and push the tag.

@{
RootModule = 'ScheduledTaskManagement.psm1'
# ModuleVersion = '' # Value will be set for each publication based on the tag ref. Defaults to '0.0.0' in development environments and regular CI builds
GUID = 'df816621-ce49-41d2-8523-19122d51c3a4'
Author = 'The Oh Brothers'
CompanyName = 'The Oh Brothers'
Copyright = '(c) 2019 The Oh Brothers'
Description = 'A PowerShell module for non-interactive management of Scheduled Tasks.'
PowerShellVersion = '3.0'
# PowerShellHostName = ''
# PowerShellHostVersion = ''
# DotNetFrameworkVersion = ''
# CLRVersion = ''
# ProcessorArchitecture = ''
# RequiredModules = @()
# RequiredAssemblies = @()
# ScriptsToProcess = @()
# TypesToProcess = @()
# FormatsToProcess = @()
# NestedModules = @()
FunctionsToExport = @(
'Setup-ScheduledTask'
)
CmdletsToExport = @()
VariablesToExport = @()
AliasesToExport = @()
# DscResourcesToExport = @()
# ModuleList = @()
# FileList = @()
PrivateData = @{
# PSData = @{ # Properties within PSData will be correctly added to the manifest via Update-ModuleManifest without the PSData key. Leave the key commented out.
Tags = @(
'taskscheduler'
'scheduledtasks'
'tasks'
)
LicenseUri = 'https://raw.githubusercontent.com/theohbrothers/ScheduledTaskManagement/master/LICENSE'
ProjectUri = 'https://github.com/theohbrothers/ScheduledTaskManagement'
# IconUri = ''
# ReleaseNotes = ''
# Prerelease = ''
# RequireLicenseAcceptance = $false
# ExternalModuleDependencies = @()
# }
# HelpInfoURI = ''
# DefaultCommandPrefix = ''
}
}
Loading

0 comments on commit c2f6154

Please sign in to comment.