Skip to content

Instantly share code, notes, and snippets.

@MVKozlov
MVKozlov / Show-MessageBox.ps1
Last active June 1, 2023 14:15
Powershell: Show GUI Messagebox and wait for user input or timeout
<#
.SYNOPSIS
Show GUI Messagebox
.DESCRIPTION
Show GUI Messagebox and wait for user input or timeout
.PARAMETER Message
Message to show
.PARAMETER Title
Messagebox title
.PARAMETER Buttons
<#
.SYNOPSIS
Sony Camera XML to DVDT converter
.DESCRIPTION
Sony Camera XML to DVDT converter
.EXAMPLE
PS C:\> Convert-Xml2Dvdt.ps1 D:\C0007M01.XML
Convert D:\C0007M01.XML to D:\C0007M01.DVDT
date: 07/08/2020 16:31:47 duration: 336 fps: 25
.EXAMPLE
@MVKozlov
MVKozlov / redmine gitlab sync
Created December 28, 2018 11:53 — forked from jakimowicz/redmine gitlab sync
simple (and dirty) sync between redmine issues and gitlab issues
#!/usr/bin/env ruby
require 'faraday'
require 'json'
require 'gitlab'
module Redmine
Host = nil
APIKey = nil
@MVKozlov
MVKozlov / Install-MSI.ps1
Created October 12, 2017 07:15
Install MSI Remotely
<#
.SYNOPSIS
Install MSI package by copy-run-remove
.DESCRIPTION
Install MSI package by copy-run-remove
.PARAMETER ComputerName
Remote computer name
.PARAMETER MSI
Path to msi package
.NOTES
@MVKozlov
MVKozlov / Backup-LogArchive.ps1
Last active August 29, 2017 12:21
Backup log files into date-named archives with folder structure saving.
# Needed DotNetZip.dll from https://github.com/haf/DotNetZip.Semverd
# in script directory
param(
$inputPath,
$outputPath,
$ArchivePrefix = 'Arch',
$days = 7
)
$inputpath = $inputpath -replace '\\$' # remove trailing \
function Set-LocalGroupMember {
[CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='High')]
param(
[Parameter(ValueFromPipeline=$true, Position=0)]
[string[]]$ComputerName = '.',
[Parameter(ValueFromPipeline=$false, Position=1)]
[string[]]$GroupName = 'Administrators',
[Parameter(ValueFromPipeline=$false, Position=2)]
[string]$Member,
[Parameter(Mandatory=$true, ParameterSetName='remove')]
<#
.SYNOPSIS
Generate set of passwords
.DESCRIPTION
Generate set of passwords based on character usage rules
.OUTPUTS
Array of string
.PARAMETER Length
The password length
.PARAMETER Count
var wsh = WScript.CreateObject("WScript.Shell")
//
// Pin item from command line to taskbar//
function PinToTaskbar(program) {
program = wsh.ExpandEnvironmentStrings(program);
var fp = program.split("\\");
var name = fp.pop()
var path = fp.join('\\')
var shap = WScript.CreateObject("Shell.Application");
var fld = shap.Namespace(path);
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
. "$here\$sut"
Describe "Test RSJob Throttling" {
It "Full Pipe input" {
$StartDate = Get-Date
Test-RSJob $true
$EndDate = Get-Date
( $EndDate - $StartDate ).TotalSeconds -gt 25 | Should be $True
function Test-RSJob([bool]$FullPiping=$true) {
$ScriptBlock = { "{0}: {1}" -f $_, [DateTime]::Now; Start-Sleep -Seconds 5 }
$params = @{ Batch='throttletest'; ScriptBlock=$ScriptBlock; Throttle=5 }
if ($FullPiping) {
$jobs = 1..25 | Start-RSJob @params
}
else {
$jobs = 1..25 | Foreach-Object { $_ | Start-RSJob @params }
}
$jobs | Wait-RSJob | Receive-RSJob