Skip to content

Instantly share code, notes, and snippets.

@peetrike
peetrike / Set-SecretName.ps1
Last active June 14, 2022 13:10
SecretServer - sample scripts
#Requires -Version 5.1
#Requires -Modules Thycotic.SecretServer
[CmdletBinding(
SupportsShouldProcess
)]
param (
[parameter(
Mandatory,
ParameterSetName = 'FolderName'
<#
.SYNOPSIS
Splits .CSV file into parts.
#>
param (
[parameter(
Mandatory = $true
)]
[string]
# File name to split
@peetrike
peetrike / Start-AsAdmin.ps1
Last active March 24, 2021 20:23
Starts given PowerShell commands in elevated Powershell process
#Requires -version 2.0
function Start-AsAdmin {
<#
.Synopsis
Starts given PowerShell commands in elevated Powershell
.Description
Runs given Powershell commands in elevated environment.
@peetrike
peetrike / Set-FirewallFilter.ps1
Last active June 14, 2022 14:01
Create address filter for reaching remote server, if it's network connection is Public
#Requires -Modules NetSecurity
# Remote admin network
$RemoteNet = '1.2.3.4/255.255.255.248'
$AddressFilter = Get-NetFirewallRule -Group '@FirewallAPI.dll,-30267' |
Where-Object Profile -like 'Public' |
Get-NetFirewallAddressFilter
if ($AddressFilter.RemoteAddress -NotContains $RemoteNet) {
$remoteFilter = @($AddressFilter.RemoteAddress) + $RemoteNet