Article archive
Create certificate using SelfSSL7 tool
02/11/2012 10:41
#Create Certificate - use SelfSSL7 tool
#input parameters: $certificateName, $iisSiteName. SelfSSL7.exe must be copied to the script location.
$certificate=get-childitem -path cert:\LocalMachine\Root|where-object {$_.Subject -match $certificateName}
if($certificate -eq...
Add registry DWORD value
02/11/2012 09:50
#you can go to the psdrive directly, but don't need
set-location hklm: #for HKEY_LOCAL_MACHINE
#go to the lsa registry
Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
#get item from registry if exists
$p=Get-ItemProperty -Path...
web.config file modification
01/11/2012 04:11
#web.config file modification
#1. get web.config path and access
$iisSiteName="YourSiteName"
import-module WebAdministration
$webConfigPath=(get-childitem iis:\sites |where-object {$_.Name -eq $iisSiteName}).PhysicalPath
$webConfigPath+="\web.config"
if(!(test-path...
Get and set folder permission, powershell elevated privileges
01/11/2012 03:10
get-acl -path $webConfigPath
#Equivalent of elevated privileges in C#
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Sharepoint")
[Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges(
{
...
Powershell drives
31/10/2012 21:32
PS> Get-PSDrive
Name Provider Root CurrentLocation
---- -------- ---- ---------------
A FileSystem A:\
Alias Alias
C FileSystem C:\ ...
Remove ssl binding
31/10/2012 17:20
There are only code examples here for different access to objects. This code itself doesn't have funcionality (no sense here).
Import-Module WebAdministration
Remove-Item -path "IIS:\SslBindings\0.0.0.0!443" #detach certificate from the site
//access iis structure
dir...
Approve all files in library
30/10/2012 21:43
internal static void ApproveAllSubfolders(SPFolder folder, StringBuilder writer, bool needsApproval)
{
if (folder.SubFolders != null)
{
...
Get SPFolder from SPList
30/10/2012 21:40
SPList list = web.Lists.TryGetList(libraryName);
if (list != null)
{
...
Write error to log
28/10/2012 18:46
//define category, not needed to use static or internal
//Area will be 'Unknown' in this case
internal static SPDiagnosticsCategory category =
new SPDiagnosticsCategory("Approve Files", TraceSeverity.Unexpected,...
Detect if Approving Enabled
27/10/2012 16:30
string libraryName = "Style library";
//this describes library settings/version settings
//you have to approve file
bool approvingEnabled = Web.Lists[libraryName].EnableModeration;
//it's...
Items: 261 - 270 of 384