This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function New-ZipCompress | |
{ | |
[CmdletBinding(DefaultParameterSetName="safe")] | |
param( | |
[parameter( | |
mandatory, | |
position = 0, | |
valuefrompipeline, | |
valuefrompipelinebypropertyname)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function New-OSUser | |
{ | |
<# | |
.Synopsis | |
Create New user | |
.DESCRIPTION | |
User will create as you passed Credential. | |
.EXAMPLE | |
New-OSUser -Credential (Get-Credential) -Groups Administrators | |
# create new user with Group assigned Administrators |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
configuration UserAndGroup | |
{ | |
param | |
( | |
[parameter(Mandatory = 1)] | |
[PSCredential[]]$credential, | |
[parameter(Mandatory = 0)] | |
[string]$Group = "Administrators" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PowerShell の String中への変数埋め込みってば罠だらけね! | |
# 例 に示す変数をString中に表示するには5つ方法がある | |
$hoge = @{hoge = "hoge"} | |
$fuga = "fuga" | |
#1. 直 (Property指定がだめ | |
"$hoge" | |
'$hoge' | |
"$hoge.hoge" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Chef Recipe rule | |
[cookbook] 'Nae' do | |
[Key_name] "[key_value]" | |
[value_name] "[value_value]" | |
end | |
# Chef DSC call EnvironemtResource with : https://github.com/opscode-cookbooks/dsc | |
env 'editor' do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Do you think is work? NO........ | |
powershell_script "executionpolicy" do | |
code 'Set-ExecutionPolicy RemoteSigned' | |
not_if "(Get-ExecutionPolicy -Scope LocalMachine) -eq 'RemoteSiggned'" | |
end | |
powershell_script "smbsharelogs" do | |
code 'New-SMBShare logshare C:\logs' | |
not_if 'Get-SMBShare logshare' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Configuraion sample | |
Configuration WebServer | |
{ | |
WindowsFeature IIS | |
{ | |
Ensure = "Present" | |
Name = "Web-Server" | |
IncludeAllSubFeature = $false | |
LogPath = "C:\Logs\DSC\WindowsFeature\Web-Server.txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Configuration Service | |
{ | |
Service WinRM | |
{ | |
Name = "WinRM" | |
State = "Running" | |
StartupType = "Automatic" | |
} | |
Service Winmgmt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Configuration Remote | |
{ | |
param | |
( | |
[Parameter(Mandatory = 1, Position = 0)] | |
[pscredential]$Credential | |
) | |
User Remote | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Configuration Service | |
{ | |
$service = "WinRM", "Winmgmt" | |
$state = "Running" | |
$startupType = "Automatic" | |
foreach ($x in $service) | |
{ | |
Service $x | |
{ |