Thursday 22 August 2013

Powershell: Create Folder/Directory if doesn't exists

Simple script for creating new folders.

# Create folder if it doesn't exists
function CreteFolder([String]$folderPath)
{
if ((Test-Path $folderPath) -ne $True)
        { New-Item $folderPath -type directory }
}

Thursday 18 July 2013

Powershell: How to get members of AD security group

all - AD security group

Get-ADGroupMember all 

Displays only "usernames":
Get-ADGroupMember all | Select SamAccountName

Snippet for Iterating through all users

$Users=Get-ADGroupMember all | Select SamAccountName

foreach ($User in $Users)
{
Write-Host $User.SamAccountName

}

Saturday 6 April 2013

Unable to connect to Windows 7 file share

While trying to connect to Windows 7 machine (from Mac or PC) over the network I was constantly receving messages:"Unable to connect"

On "server" machine I noticed following error in event viewer:
Soruce: Srv
Event Id:2017
"The server was unable to allocate from the system nonpaged pool because the server reached the configured limit for nonpaged pool allocations."

The server was unable to allocate from the system nonpaged pool because the pool was empty.


Problem occurs when multiple computers are trying to connect to one Windows 7 "server" machine. Do following procedure:


Set the following registry key to ’1':

HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\LargeSystemCache

and set the following registry key to ’3':

HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\Size

Restart computer or just "Server" service, fixed! :)