Skip to content

Instantly share code, notes, and snippets.

View petrsvihlik's full-sized avatar
😋
Strategizing...

Petr Švihlík petrsvihlik

😋
Strategizing...
View GitHub Profile
# Configure path to the root of your web project
$webRoot = "C:\inetpub\wwwroot\Kentico\CMS\"
$bin = $webRoot + "bin\"
# Load settings from web.config
[System.AppDomain]::CurrentDomain.SetData("APP_CONFIG_FILE", $webRoot + "web.config")
Add-Type -AssemblyName System.Configuration
[Configuration.ConfigurationManager].GetField("s_initState", "NonPublic, Static").SetValue($null, 0)
[Configuration.ConfigurationManager].GetField("s_configSystem", "NonPublic, Static").SetValue($null, $null)
([Configuration.ConfigurationManager].Assembly.GetTypes() | where {$_.FullName -eq "System.Configuration.ClientConfigPaths"})[0].GetField("s_current", "NonPublic, Static").SetValue($null, $null)
@petrsvihlik
petrsvihlik / kentico-vs-powershell-rest.ps1
Last active August 2, 2016 12:21
Using Kentico REST API in PowerShell
$url = "http://localhost/kentico/rest/CMS.User/administrator"
# Enter correct username:password
$credentialsBytes = [System.Text.Encoding]::UTF8.GetBytes("administrator:")
$credentialsEncoded = [System.Convert]::ToBase64String($credentialsBytes)
$headers = @{}
$headers.Add("Authorization", "Basic $($credentialsEncoded)")
# Change requested mime/type