Showing posts with label Powershell. Show all posts
Showing posts with label Powershell. Show all posts

12.23.2015

Exploring WMI

Free tools for exploring the Windows Management Instrumentation (WMI). Free registration is required. They also have many free e-book and script examples.
http://www.sapien.com/downloads

4.10.2014

SharePoint 2010 - Enabling the Developer Dashboard

Enabling via powershell:

$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$dashboardSetting = $contentService.DeveloperDashboardSettings
$dashboardSetting.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::On
$dashboardSetting.Update()


http://msdn.microsoft.com/en-us/library/office/gg512103(v=office.14).aspx
http://msdn.microsoft.com/en-us/library/office/ff512745(v=office.14).aspx

2.03.2014

Powershell - File Renaming

Here is a quick powershell script to tidy files that are not properly formatted for the web.

Get-ChildItem C:\Temp\rename\* -Recurse | Rename-Item -NewName {$_.name -creplace '[^A-Za-z1234567890.]','_' }
Get-ChildItem C:\Temp\rename\* -Recurse | Rename-Item -NewName {$_.name -replace '___','_' }
Get-ChildItem C:\Temp\rename\* -Recurse | Rename-Item -NewName {$_.name -replace '__','_' }

1.10.2014

Powershell - Transferring Files from Server to Server

This is a nice little trick to get powershell to transfer files from one server directly without using domain admin credentials, or setting up an intermediary share directory. The credentials here are for the destination server. This creates a temporary network shared drive on the source server, transfers the file, then removes the shared directory.

$DriveUsername = "SERVER\USERNAME"
$DrivePassword = "PASSWORD"
$LocalFile = "C:\DIRECTORY\FILENAME.csv"
$Drive = "T:"
$RemoteFile = "$Drive\FILENAME.csv"
$UNC = "\\10.10.10.10\C$\DIRECTORY"
$net = new-object -ComObject WScript.Network

$net.MapNetworkDrive($Drive, $UNC, $false, $DriveUsername, $DrivePassword)
Copy-Item $LocalFile $RemoteFile
$net.removenetworkdrive($Drive)