Skip to content
Permalink
Browse files

Transfer development to github

  • Loading branch information...
PowerShellTeam committed Apr 15, 2015
0 parents commit 63fba0a50bb0bc31f6e90c495a046a268919e6cb
@@ -0,0 +1,85 @@
#--------------------------------------------------------------------------------- #The sample scripts are not supported under any Microsoft standard support #program or service. The sample scripts are provided AS IS without warranty #of any kind. Microsoft further disclaims all implied warranties including, #without limitation, any implied warranties of merchantability or of fitness for #a particular purpose. The entire risk arising out of the use or performance of #the sample scripts and documentation remains with you. In no event shall #Microsoft, its authors, or anyone else involved in the creation, production, or #delivery of the scripts be liable for any damages whatsoever (including, #without limitation, damages for loss of business profits, business interruption, #loss of business information, or other pecuniary loss) arising out of the use #of or inability to use the sample scripts or documentation, even if Microsoft #has been advised of the possibility of such damages #---------------------------------------------------------------------------------

function Get-TargetResource
{
[CmdletBinding()]
[OutputType([Hashtable])]
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]
$TimeZone
)

#Get the current TimeZone
$CurrentTimeZone = Invoke-Expression "tzutil.exe /g"

$returnValue = @{
TimeZone = $CurrentTimeZone
}

#Output the target resource
$returnValue
}


function Set-TargetResource
{
[CmdletBinding(SupportsShouldProcess=$true)]
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]
$TimeZone
)

#Output the result of Get-TargetResource function.
$GetCurrentTimeZone = Get-TargetResource -TimeZone $TimeZone

If($PSCmdlet.ShouldProcess("'$TimeZone'","Replace the System Time Zone"))
{
Try
{
Write-Verbose "Setting the TimeZone"
Invoke-Expression "tzutil.exe /s ""$TimeZone"""
}
Catch
{
$ErrorMsg = $_.Exception.Message
Write-Verbose $ErrorMsg
}
}
}


function Test-TargetResource
{
[CmdletBinding()]
[OutputType([Boolean])]
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]
$TimeZone
)

#Output from Get-TargetResource
$Get = Get-TargetResource -TimeZone $TimeZone

If($TimeZone -eq $Get.TimeZone)
{
return $true
}
Else
{
return $false
}
}

Export-ModuleMember -Function *-TargetResource



@@ -0,0 +1,9 @@

[ClassVersion("1.0.0.0"), FriendlyName("xTimeZone")]
class xTimeZone : OMI_BaseResource
{
[Key, Description("Specifies the TimeZone.")] String TimeZone;
};



@@ -0,0 +1,26 @@
#--------------------------------------------------------------------------------- #The sample scripts are not supported under any Microsoft standard support #program or service. The sample scripts are provided AS IS without warranty #of any kind. Microsoft further disclaims all implied warranties including, #without limitation, any implied warranties of merchantability or of fitness for #a particular purpose. The entire risk arising out of the use or performance of #the sample scripts and documentation remains with you. In no event shall #Microsoft, its authors, or anyone else involved in the creation, production, or #delivery of the scripts be liable for any damages whatsoever (including, #without limitation, damages for loss of business profits, business interruption, #loss of business information, or other pecuniary loss) arising out of the use #of or inability to use the sample scripts or documentation, even if Microsoft #has been advised of the possibility of such damages #---------------------------------------------------------------------------------

Configuration SetTimeZone
{
Param
(
[String[]]$NodeName = $env:COMPUTERNAME,

[Parameter(Mandatory = $true)]
[ValidateNotNullorEmpty()]
[String]$SystemTimeZone
)

Import-DSCResource -ModuleName xTimeZone

Node $NodeName
{
xTimeZone TimeZoneExample
{
TimeZone = $SystemTimeZone
}
}
}

SetTimeZone -NodeName "localhost" -SystemTimeZone "Tonga Standard Time"
Start-DscConfiguration -Path .\SetTimeZone -Wait -Verbose -Force
21 LICENSE
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Microsoft Corporation.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
@@ -0,0 +1,8 @@
{{AppVeyor build status badge for master branch}}

#{{ModuleName}}

{{Description}}

## Contributing
Please check out common DSC Resources [contributing guidelines](https://github.com/PowerShell/DscResource.Kit/blob/master/CONTRIBUTING.md).
@@ -0,0 +1,25 @@
install:
- cinst -y pester
- git clone https://github.com/PowerShell/DscResource.Tests

build: false

test_script:
- ps: |
$testResultsFile = ".\TestsResults.xml"
$res = Invoke-Pester -OutputFormat NUnitXml -OutputFile $testResultsFile -PassThru
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile))
if ($res.FailedCount -gt 0) {
throw "$($res.FailedCount) tests failed."
}
on_finish:
- ps: |
$stagingDirectory = (Resolve-Path ..).Path
$zipFile = Join-Path $stagingDirectory "$(Split-Path $pwd -Leaf).zip"
Add-Type -assemblyname System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::CreateFromDirectory($pwd, $zipFile)
@(
# You can add other artifacts here
(ls $zipFile)
) | % { Push-AppveyorArtifact $_.FullName }
@@ -0,0 +1,37 @@
@{

# Version number of this module.
ModuleVersion = '1.0.0'

# ID used to uniquely identify this module
GUID = 'd75e53f2-47fc-4ee7-97af-8d257d3e0151'

# Author of this module
Author = 'OneScript Team'

# Company or vendor of this module
CompanyName = 'Microsoft Corporation'

# Copyright statement for this module
Copyright = '(c) 2014 Microsoft Corporation. All rights reserved.'

# Description of the functionality provided by this module
Description = 'This DSC Resources can easily set the System Time Zone.'

# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '4.0'

# Functions to export from this module
FunctionsToExport = 'Get-TargetResource', 'Test-TargetResource', 'Set-TargetResource'

# Cmdlets to export from this module
CmdletsToExport = '*'

# Variables to export from this module
VariablesToExport = '*'

# Aliases to export from this module
AliasesToExport = '*'

}

@@ -0,0 +1,131 @@
<body>
<div id="longDesc">
<div id="longDesc">
<h1 style="color:#2e74b5; font-family:Calibri Light; font-size:large">
Introduction
</h1>
<div id="longDesc">
<span style="font-family:Calibri; font-size:medium">
<p>
The<strong> xTimeZone</strong> module is a part of the Windows PowerShell Desired State Configuration (DSC) Resource Kit,
which is a collection of DSC Resources. This module contains the <strong>xTimeZone</strong> resource.
This resource enables you to set one or more IE homepages using PowerShell DSC.
</p>
<p>
<strong>All of the resources in the DSC Resource Kit are provided AS IS, and are not supported through any Microsoft standard support program or service. The &quot;x&quot; in xTimeZone stands for experimental</strong>, which means that these resources
will be <strong>fix forward</strong> and monitored by the module owner(s).
</p>
<p>Please leave comments, feature requests, and bug reports in the Q &amp; A tab for this module.</p>
<p>
If you would like to modify <strong>xTimeZone</strong> module, feel free. When modifying, please update the module name, resource friendly name, and MOF class name (instructions below). As specified in the license, you may copy or modify
this resource as long as they are used on the Windows Platform.
</p>
<p>
For more information about Windows PowerShell Desired State Configuration, check out the blog posts on the
<a href="http://blogs.msdn.com/b/powershell/"><span style="color:#0000ff">PowerShell Blog</span></a> (<a href="http://blogs.msdn.com/b/powershell/archive/2013/11/01/configuration-in-a-devops-world-windows-powershell-desired-state-configuration.aspx"><span style="color:#0000ff">this</span></a>
is a good starting point). There are also great community resources, such as <a href="http://powershell.org/wp/tag/dsc/">
<span style="color:#0000ff">PowerShell.org</span>
</a>, or <a href="http://www.powershellmagazine.com/tag/dsc/">
<span style="color:#0000ff">PowerShell Magazine</span>
</a>. For more information on the DSC Resource Kit, check out
<a href="http://go.microsoft.com/fwlink/?LinkID=389546"><span style="color:#0000ff">this blog post</span></a>.
</p>
<h1 style="color:#2e74b5; font-family:Calibri Light; font-size:large">Installation</h1>
<p>To install <strong>xTimeZone</strong> module</p>
<ul style="list-style-type:disc; direction:ltr">
<li>
If you are using WMF4 / PowerShell Version 4: Unzip the content under $env:ProgramFiles\WindowsPowerShell\Modules folder
</li>
<li>
If you are using WMF5 Preview: From an elevated PowerShell session run &lsquo;Install-Module xTimeZone&rsquo;
</li>
</ul>
<p>To confirm installation:</p>
<ul style="list-style-type:disc; direction:ltr">
<li>
Run <strong>Get-DSCResource</strong> to see that the resources listed above are among the DSC Resources displayed
</li>
</ul>
<h1 style="color:#2e74b5; font-family:Calibri Light; font-size:large">Requirements</h1>
<p>
This module requires PowerShell v4.0, which ships in Windows 8.1 or Windows Server 2012R2. To easily use PowerShell 4.0 on older operating systems,
<a href="http://www.microsoft.com/en-us/download/details.aspx?id=40855"><span style="color:#0000ff">install WMF 4.0</span></a>.
Please read the installation instructions that are present on both the download page and the release notes for WMF 4.0.
</p>
<h1 style="color:#2e74b5; font-family:Calibri Light; font-size:large">Details</h1>
<p>The <strong>xTimeZone</strong> resource has following properties:</p>
<ul style="list-style-type:disc; direction:ltr">
<li>
<strong>TimeZon</strong>: Specifies the Time Zone
</li>
</ul>
<h1 style="color:#2e74b5; font-family:Calibri Light; font-size:large">Renaming Requirements</h1>
<p>When making changes to these resources, we suggest the following practice:</p>
<ol style="list-style-type:decimal; direction:ltr">
<li>
Update the following names by replacing MSFT with your company/community name and replacing the
<strong>&quot;x&quot;</strong> with <strong>&quot;c&quot;</strong> (short for &quot;Community&quot;) or another prefix of your choice:
<ul>
<li>
<strong>Module name (ex: x<span style="font-family:Calibri; font-size:medium"><strong>TimeZone</strong></span></strong> becomes
<strong>c<span style="font-family:Calibri; font-size:medium"><strong>TimeZone</strong></span></strong>)
</li>
<li>
<strong>Resource folder (ex: MSFT_</strong><span style="font-family:Calibri; font-size:medium"><strong>xTimeZone</strong></span> becomes
<strong>Contoso_x</strong><span style="font-family:Calibri; font-size:medium"><strong>TimeZone</strong></span>)
</li>
<li>
<strong>Resource Name (ex: MSFT_<span style="font-family:Calibri; font-size:medium"><strong>xTimeZone</strong></span></strong> becomes
<strong>Contoso_c</strong><span style="font-family:Calibri; font-size:medium"><strong>TimeZone</strong></span>)
</li>
<li>
<strong>
Resource Friendly Name (ex: <span style="font-family:Calibri; font-size:medium">
<strong>xTimeZone</strong>
</span>
</strong>becomes <strong>c<span style="font-family:Calibri; font-size:medium"><strong>TimeZone</strong></span></strong>)
</li>
<li>
<strong>MOF class name (ex: MSFT_x<span style="font-family:Calibri; font-size:medium"><strong>TimeZone</strong></span></strong> becomes
<strong>Contoso_c<span style="font-family:Calibri; font-size:medium"><strong>TimeZone</strong></span></strong>)
</li>
<li>
<strong>Filename for the &lt;resource&gt;.schema.mof (ex: MSFT_x<span style="font-family:Calibri; font-size:medium"><strong>TimeZone</strong></span></strong>.schema.mof becomes
<strong>Contoso_c<span style="font-family:Calibri; font-size:medium"><strong>TimeZone</strong></span></strong>.schema.mof)
</li>
</ul>
</li>
<li>Update module and metadata information in the module manifest </li>
<li>Update any configuration that use these resources </li>
</ol>
<p>
<em>
We reserve resource and module names without prefixes (&quot;x&quot; or &quot;c&quot;) for future use (e.g. &quot;MSFT_TimeZone&quot; or &quot;MSFT_ADUser&quot;). If the next version of Windows Server ships with a &quot;TimeZone&quot; resource, we don't want to break
any configurations that use any community modifications. Please keep a prefix such as &quot;c&quot; on all community modifications.
</em>
</p>
<h1 style="color:#2e74b5; font-family:Calibri Light; font-size:large">Versions</h1>
<p>1.0.0.0</p>
<ul style="list-style-type:disc; direction:ltr">
<li>
Initial release with the following resources
<ul style="list-style-type:circle">
<li>
<span style="font-family:Calibri; font-size:medium">xTimeZone</span>
</li>
</ul>
</li>
</ul>
<h1 style="margin-bottom:0pt; font-family:Calibri Light; color:#2e74b5; font-size:large">
Examples
</h1>
<p><strong>Setting the Time Zone</strong></p>
<p>In the Examples folder, SetTimeZone.ps1 demonstrates how to set the local time zone to "Tonga Standard Time".</p>
</span>
</div>
</div>
</div>


</body>
</html>

0 comments on commit 63fba0a

Please sign in to comment.
You can’t perform that action at this time.