Sign in
|
Join PowerShell.com!
|
Help
Home
PowerTips
Ask the Experts
Forums
Webcasts
Blogs
eBookV2
Script Library
Twitter Grid
Modules
QuickClick
Scripts
Snippets
Videos
Library
»
Script Library
»
Local Accounts
»
Configure Windows local Guest account
Configure Windows local Guest account
Share
|
Browse Library
Module Library
QuickClick Library
Script Library
Active Directory
BizTalk
Citrix
Clustering
Desktop
Exchange Server 2003
Exchange Server 2007
File System
Group Policy
Internet Information Server (IIS)
Local Accounts
Logs
Microsoft Office
Microsoft Team Foundation Server
MySQL
Networking
Registry
Remote Desktop Services
Remoting
Security
SharePoint
SQL Server
System Center Virtual Machine Manager
System Center Configuration Manager
System Center Operations Manager
Tutorial
Terminal Server
Using .Net
Virtual Server
VMware
Windows 7
Windows HPC
Windows Server 2000
Windows Server 2003
Windows Server 2008
Windows XP
WMI
Misc
Snippet Library
Video Library
Members Only
Tags
administrator
ADSI
group
local
local. WinNT
member
psbase
users
WinNT
View more
Previous
|
Next
|
View all files
|
View Slideshow
Download
posted by
tao.yang
06-01-2009
Downloads: 389
File size: 798 B
Views: 2,025
Embed
Configure Windows local Guest account
$ColAccounts
=
Get-WmiObject
Win32_UserAccount
$strNewGuestName
=
"<ENTER_NEW_GUEST_ACCOUNT_NAME_HERE>"
$strGuestPassword
=
ConvertTo-SecureString
"<ENTER_PASSWORD_HERE>"
-AsPlainText
-force
$strGuestPw
=
[
Runtime.InteropServices.Marshal
]::
PtrToStringAuto
([
Runtime.InteropServices.Marshal
]::
SecureStringToBSTR
(
$strGuestPassword
))
$ColAccounts
|
foreach-object
{
if
((
$_
.
SID.substring
(0, 8)
-match
"S-1-5-21"
)
-and
(
$_
.
SID.substring
(
$_
.
SID.length
-
3, 3)
-match
"501"
))
{
#Set password
$computer
=
[
ADSI
]
"WinNT://$env:computername,computer"
$objGuest
=
$computer
.
psbase.children.Find
(
$_
.
name
)
$objGuest
.
SetPassword
(
$strGuestPw
)
#$objGuest.psbase.CommitChanges()
#Disable
$_
.
disabled
=
$true
$_
.
put
() |
Out-Null
#Rename
$_
.
Rename
(
$strNewGuestName
) |
Out-Null
}
}
In Windows 2003, the local guest account has blank password and by default it is named “Guest". Below is the script I wrote in Powershell to rename the guest account (no matter what the current name is) and reset th password
Copyright 2011 PowerShell.com. All rights reserved.