Skip to content

Instantly share code, notes, and snippets.

View janikvonrotz's full-sized avatar
:octocat:

Janik von Rotz janikvonrotz

:octocat:
View GitHub Profile
@janikvonrotz
janikvonrotz / Instruction.md
Created January 29, 2014 15:29
PowerShell: Moving an Event Source to a Different Windows Event Log #Markdown #WindowsServer #PowerShell

It is typically best practice when developing .NET applications, including SharePoint customizations, to create an event source for Windows Event Logging while installing the application. Each event source on a Windows computer is tied to a specific log upon registration. I recently provided guidance on how to move an event source to use its own brand new event log. The following lines of PowerShell can do this quickly. Unless your .NET application has the event log hardcoded into itself, which it shouldn’t because the event source should be registered to a log during installation, then the move shouldn’t require any code changes.

Remove-EventLog -Source MyCustomApplicationSource
New-EventLog -Source MyCustomApplicationSource -LogName MyNewOrExistingWindowsEventLog

I found that I had to reboot the machine after executing the above lines of PowerShell for this change to fully take effect.

@janikvonrotz
janikvonrotz / Create-PathAndFilename.ps1
Created February 6, 2014 12:16
PowerShell: Handle not existing file paths or filenames from a unspecific path #PowerShell
$PathAndFilename = Get-PathAndFilename $Path
if(-not $PathAndFilename.Filename){$PathAndFilename.Filename =$AlternativeFilename}
if(-not $PathAndFilename.Path){$PathAndFilename.Path = (Get-Location).Path}
if(-not (Test-Path $PathAndFilename.Path)){New-Item -Path $PathAndFilename.Path -ItemType Directory}
$Path = Join-Path $PathAndFilename.Path ($PathAndFilename.Filename)
@janikvonrotz
janikvonrotz / Backup-SPSites.ps1
Created February 7, 2014 09:48
PowerShell: Backup SharePoint Sites #SharePoint #PowerShell #CompanyIOZ
#Backup Settings
$backupPath = "E:\SharePointBackups";
$RentationDays = "1"
#Mail Settings
$emailFrom = "sharepointbackup@vbl.ch"
$emailTo = "helpdesk@vbl.ch"
$smtpServer = "mail.vbl.ch"
$SuccessNotification = 0
######################
@janikvonrotz
janikvonrotz / BuildFarm.ps1
Last active August 29, 2015 13:56
PowerShell: Install SharePoint 2013 #PowerShell #SharePoint #CompanyIOZ
#Start Schritt 1
$snapin = Get-PSSnapin Microsoft.SharePoint.Powershell -ErrorVariable err -ErrorAction SilentlyContinue
if($snapin -eq $null){
Add-PSSnapin Microsoft.SharePoint.Powershell
}
function Write-Info([string]$msg){
Write-Host "$($global:indent)[$([System.DateTime]::Now)] $msg"
}
@janikvonrotz
janikvonrotz / CheckDBConnection.php
Created February 12, 2014 17:04
Check Database Connection #PHP #MySQL
<!--
#--------------------------------------------------#
# Title: Check MySQL DB Connection
#--------------------------------------------------#
# File name: CheckDBConnection.php
# Description:
# Tags: mysql, php, connection, check
# Project:
#
# Author: Janik von Rotz
@janikvonrotz
janikvonrotz / Setup-ADFSRelyingPartyTrust.ps1
Created February 13, 2014 17:28
PowerShell: Setup a Active Directory Federation Service Relying Party Trust #PowerShell #ADFS
# 1. Get your ADFS Federation Metadata
$FederationMetadataUrl = (Get-ADFSEndpoint | where{$_.Protocol -eq "Federation Metadata"}).FullUrl.OriginalString
# 2. Send Url to Umantis
# 3. Add Relying Party Trust
## customer settings
@janikvonrotz
janikvonrotz / Set-SPDefaultPermissions.ps1
Created February 14, 2014 10:00
PowerShell: Set SharePoint Default Permissions #PowerShell #SharePoint
<#
$Metadata = @{
Title = "SharePoint Default Settings"
Filename = "Set-SPDefaultSettings.ps1"
Description = ""
Tags = "powershell, script, sharepoint, default settings"
Project = ""
Author = "Janik von Rotz"
AuthorContact = "http://www.janikvonrotz.ch"
CreateDate = "2013-05-07"
@janikvonrotz
janikvonrotz / Create-SPMySiteThumbnails.ps1
Created February 14, 2014 10:00
PowerShell: Create SharePoint MySite Thumbnails #PowerShell #SharePoint
if((Get-PSSnapin 'Microsoft.SharePoint.PowerShell' -ErrorAction SilentlyContinue) -eq $null){Add-PSSnapin 'Microsoft.SharePoint.PowerShell'}
Update-SPProfilePhotoStore -CreateThumbnailsForImportedPhotos 1 -MySiteHostLocation http://mysite.vbl.ch
@janikvonrotz
janikvonrotz / Disable Extended Protection ADFS.ps1
Created February 17, 2014 12:37
PowerShell: Disable Extended Protection in ADFS 2.0 to allow Google Chrome and Firefox to Authenticate Using NTLM #ADFS #Office365 #PowerShell
PS C:\Users\su-adfs> Set-ADFSProperties -ExtendedProtectionTokenCheck:None
WARNING: PS0038: This action requires a restart of the AD FS Windows Service. If you have deployed a federation server
farm, restart the service on every server in the farm.
PS C:\Users\su-adfs> iisreset.exe
Attempting stop...
Internet services successfully stopped
Attempting start...
Internet services successfully restarted
@janikvonrotz
janikvonrotz / Migrate-SPOFunctions.ps1
Created February 24, 2014 09:24
PowerShell: Migrate SharePoint PowerShell functions by Jeffrey Paarhuis #PowerShell #SharePointOnline
# change function directory
cd (join-path $PSfunctions.Path "SharePoint Online")
# download latest source code
Install-PPApp "Client-side SharePoint PowerShell" -Force -IgnoreDependencies
# delete example files
Get-ChildItem | where{$_.extension -eq ".ps1" -or $_.PSIsContainer} | Remove-Item -Force -Recurse -Confirm:$false
# copy dlls to lib folder