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
$newPath = "c:\scripts\" | |
Write-host Preparing environment | |
$currentPath = [Environment]::GetEnvironmentVariable("Path",[EnvironmentVariableTarget]::User) #or ::Machine | |
if ($currentPath -like '*'+$newPath+'*') | |
{ | |
Write-host 'System environment "Path" already contains ' $newPath | |
} | |
else { | |
Write-host 'Adding ' $newPath ' to System "Path"' |
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
$user = "test" | |
$remoteFiles = Get-ChildItem "C:\img" -Filter *.png | |
foreach ($file in $remoteFiles) | |
{ | |
Write-Host Changing permission of $file.FullName | |
#change permission | |
$Acl = Get-Acl $file.FullName | |
$Ar = New-Object System.Security.AccessControl.FileSystemAccessRule($user, "FullControl", "None", "None", "Allow") | |
$Acl.SetAccessRule($Ar) |
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
# include Set-Owner | |
# https://gallery.technet.microsoft.com/scriptcenter/Set-Owner-ff4db177 | |
. .\Set-Owner.ps1 | |
$user = "testUser" | |
$remoteFiles = Get-ChildItem "C:\img" -Filter *.png | |
foreach ($file in $remoteFiles) | |
{ | |
Write-Host Changing the owner of $file.FullName to $user | |
Set-Owner -Path $file.FullName -Account $user |
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
# download.txt | |
# http://fabricjs.com/assets/25.svg | |
# http://fabricjs.com/assets/36.svg | |
$destination="img" | |
New-Item -ItemType directory -force $destination | |
$links=Get-Content download.txt | |
foreach ($link in $links) | |
{ |
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
$user = "user" | |
$pass= "password" | |
#zipballs of particular branches have syntax /repository-name/zipball/branch-name | |
$branchname = "master" | |
$linkToSnapshot = "https://github.com/a5ync/webgl/zipball/"+$branchname | |
#prepare credential header | |
$pair = "$($user):$($pass)" | |
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair)) |
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
$source = ".\img" | |
$destination = ".\deploy_" +[DateTime]::Now.ToString("yyyyMMdd-HHmmss")+".zip" | |
#compress | |
If(Test-path $destination) {Remove-item $destination} | |
Add-Type -assembly "system.io.compression.filesystem" | |
[io.compression.zipfile]::CreateFromDirectory($Source, $destination) | |
#extract | |
Expand-Archive $destination -dest .\test |
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
#e.g. zipball\a5ync-webgl-68dda42 | |
#get the first child folder of root | |
$zipballFolder = ".\zipball" | |
$targetFolder = ".\final" | |
$directoryWithNameOfCommit = Get-ChildItem $zipballFolder| Select-Object -first 1 | |
Write-Host $directoryWithNameOfCommit | |
#move the folder content to a target folder | |
join-path $zipballFolder $directoryWithNameOfCommit | |
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
#update registry | |
Write-Host Adding to startup | |
$keyRun = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' | |
$appToRun="C:\Windows\notepad.exe" | |
$label = "Hey Run Notepad" | |
Set-ItemProperty -Path $keyRun -Name $label -Value $appToRun | |
Write-Host Added to startup -foreground "green" |
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
Get-Content myTestLog.log –Wait | |
#with filters | |
Get-Content myTestLog.log -wait | where { $_ -match “WARNING” } |
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
$serviceName = "Dhcp" | |
$service = Get-Service $serviceName -ErrorAction SilentlyContinue | |
if($service) | |
{ | |
Write-host service $service.Name is $service.Status | |
} | |
else | |
{ | |
Write-host what service? |
OlderNewer