Skip to content

Instantly share code, notes, and snippets.

@weipah
weipah / getWeek.vb
Created March 27, 2012 07:37
Wochenstart und -Ende anhand eines Datums bestimmen (Access VBA, Array)
' Aufruf
Dim tage() As String
tage = getWeek(textbox.text)
Function getWeek(datum As String) As Variant
'Dim datum As String
Dim result(1) As String
Dim wochentag As Integer
Dim wStart As String
Dim wEnde As String
@weipah
weipah / XADGroupCopy.ps1
Created April 27, 2012 07:07
Copy ActiveDirectory-Groups from one user to another
function XADGroupCopy() {
param(
[parameter(Mandatory=$true,Position=0,HelpMessage="Von welchem User sollen Berechtigungen kopiert werden?")]
[String]
$fromUser,
[parameter(Mandatory=$true,Position=1,HelpMessage="Welcher User erhaelt die neuen Gruppen?")]
[String]
$toUser
)
@weipah
weipah / PasswordExpireDate.ps1
Created April 27, 2012 09:20
Find out when a user password will expire or if already expired
function Get-XADUserPasswordExpirationDate() {
Param ([Parameter(Mandatory=$false, Position=0, ValueFromPipeline=$true, HelpMessage="Identity of the Account")]
[Object] $accountIdentity )
PROCESS {
If ($accountIdentity -eq $null) {
$computer = Get-WmiObject win32_computerSystem -ComputerName "."
$user = $computer.UserName.Split("\")
$accountIdentity = $user[$user.length-1]
@weipah
weipah / getPathFromEMail.vb
Created July 27, 2012 08:18
Get full path from email in Outlook 2010
Sub Pfad_anzeigen()
Dim ordner As Outlook.MAPIFolder
Dim ordnerPfad As String
Set ordner = Application.ActiveExplorer.Selection.Item(1).parent
ordnerPfad = ordner.Name
Do Until ordner.parent = "Mapi"
Set ordner = ordner.parent
@weipah
weipah / repeating-table-auto-increment.cs
Created September 6, 2012 11:43
Auto-increment repeating table position in InfoPath
// "my:Inhalte" --> Repeating table data
public void Projektinformationen_Changed(object sender, XmlEventArgs e)
{
//e.Operation property is equal to XmlOperation.Insert or XmlOperation.Delete
XPathNavigator nav = MainDataSource.CreateNavigator();
XPathNodeIterator iter = nav.Select("/my:meineFelder/my:Inhalte/my:Position", NamespaceManager);
int i = 1;
@weipah
weipah / pollTerminalServers.ps1
Created November 26, 2012 12:41
Poll a list of Windows Terminal Servers for a specific User (Multithreading attempt 1)
function Get-XTSSession() {
Param ([Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true, HelpMessage="UserName?")]
$User )
$aco_servers = "C:\Users\adm-ml\Documents\WindowsPowerShell\Modules\PSTerminalServices\aco-terminal-servers.txt"
$workingDirectory = (get-location)
if ($user.gettype().fullname -eq "System.String") {
if ($user -ne $null -and $user.length -gt 0) {
$username = $user
@weipah
weipah / findUserOnTerminalServer.ps1
Created November 29, 2012 15:44
Poll a list of Windows Terminal Servers for a specific User (Multithreading attempt 2)
#require -version 2.0
# based on source from: http://www.nivot.org/blog/post.aspx?id=1f8255b2-05a7-4947-8dc3-01ce3c478cc2
# does not really work, because the waithandle is not processed correctly
# using $wait[$i].WaitOne() in for-loop would work, but is not the right way to process jobs in parallel
# create a pool of 10 runspaces
$pool = [runspacefactory]::CreateRunspacePool(1,10)
$pool.Open()
@weipah
weipah / import-portatour.ps1
Last active March 4, 2024 22:34
PowerShell V3 Multipart/formdata example with REST-API (Invoke-RestMethod)
function Import-Portatour {
param (
[parameter(Mandatory=$True,Position=1)] [ValidateScript({ Test-Path -PathType Leaf $_ })] [String] $FilePath,
[parameter(Mandatory=$False,Position=2)] [System.URI] $ResultURL
)
# CONST
$CODEPAGE = "iso-8859-1" # alternatives are ASCII, UTF-8
# We have a REST-Endpoint
$RESTURL = "https://my.portatour.net/a/api/ImportCustomers/"
@weipah
weipah / MassMailerHTML.ps1
Created March 19, 2015 10:45
MassMailerHTML - Inform users from ActiveDirectory per Mail with Send-Mailmessage Cmdlet
# Script to inform multiple users via Mail
# Two datasources
# 1. Old Firewall VPN Config -> Exported as XML
# 2. Active Directory Accounts
$date = (get-date)
# Which file should be send with the mail as an attachment?
$attachment = "C:\Users\xyz\Documents\beispiel-anhang.txt"
@weipah
weipah / enable-split-tunneling.ps1
Created April 6, 2016 13:30
Enable split-tunneling for a VPN connection on Windows 10
# List all VPN connections
Get-VPNConnection
# Enable split-tunneling for a specific connection
Set-VPNConnection -name "<see list>" -SplitTunneling $true