Scripts to Set Future Account Expiration Date in Active Directory
Hi All,
Can anyone help me in finding a script for setting out Future Account Expiration Date for bulk users.
Regards Sandeep Swarup S
Network Domains using VB.NET
I have 4 domains available on my local network
1- Domain1
2- Domain2
3- Domain3
4- Domain4
How can I programatically fill a dropdown list with all above domains?? I dont want to hard code these domains as these could be different when this application will be deployed in some other environment or network. I am using LDAP.
Any help will be really appreciated.
Thanks
Muhammad Akmal
GPO Security Filtering - Automation
Hi Techies,
Need help to automate the below requirement in Win2003 env thru VBScript.
We are in the department which requires lot of GPO's created on day to day basis. we need to automate the GPO creation and security filtering in a specific way. As we have lot of scripts to create GPOs I'm finding sooo difficult to automate the security filtering. I need to add a user group in that GPO security permission and need to provide "full access" permissions without "apply" permission. once applied, while we opening the security tab of that GPO and click on that specific user group, out of the 6 permissions listed in the first display, i need all the check marks enabled in allow permission column except "Full Control" and "Apply Group Policy" which needs to be kept blank.
Somebody please take this in high priority and help me out. I will keep updating the results of your hints here.
Windows 2003 bat files - extract a name and file path
Hello,
I have found an old server with several Robocopy processes on it. They execute a bunch of batch files.
There are some comments and variable declarations, but all I am interested in grabbing the name of the file, and the file path for the source and destination. Those lines all begine with:
Robocopy <source path> <target path>
I would like to go through all the files in this directory - grab the name of the file, and the Robocopy line.
The files live on a Windows 2003 SP2 server. Will Dos commands allow me to do this? Or do I require some other tool?
Thanks,
VeePee
Simple write-log function - Why can't I write a boolean result to my log file?
Hello everyone - I'm frustrated over something which should be simple: displaying a boolean result in front of a file path test. As part of a file copy script, I test the path of my source directory, to ensure the file I'm copying actually exists. I have a log file that will write out the result of this test in case it is an error. If it fails, all I want to do is see a line in my log like this: False: C:\SomePath\SomeFolder
Here is a code snip:
function write-log($WriteLine) { Add-Content -Encoding ascii -Path $logfile -value $WriteLine } $tempSource = $mySourcePath $tempDest = $destPath $CheckSource = Test-Path -Path $tempSource if ($CheckSource -eq $False) { write-log "Access Error:" write-log "$CheckSource: $tempSource" }What happens is, the boolean "False" text never appears in the log. I only see the path. I also never see the colon. What dumb thing am I doing wrong?
Many thanks in advance.
Exchange 2010 Powershell script to display all activesync devices/users
Found the script in another thread around here.
This is exactly what i'm trying to accomplish, a list with all the Activesync users, and devices, however, running the below script when the user have more than one device, just bring all the devices for that user, but it duplicates the first device information.
$racfs = Get-CASMailbox -Filter {hasactivesyncdevicepartnership -eq $true -and -not displayname -like "CAS_{*"}
#array to store final results
$stats = @()
$racfs | Foreach {
#select the properties you want from both objects (activesync props will be empty)
$m = $_ | select DisplayName, name, DeviceFriendlyName, Devicetype, DeviceUserAgent, FirstSyncTime, LastSuccessSync
#get the activesync stats
foreach ($Device in Get-ActiveSyncDeviceStatistics -Mailbox $_.Identity)
{
#populate empty active sync properties on your previous object
$m.DeviceFriendlyName = $Device.DeviceFriendlyName
$m.DeviceType = $Device.DeviceType
$m.DeviceUserAgent = $Device.DeviceUserAgent
$m.FirstSyncTime = $Device.FirstSyncTime
$m.LastSuccessSync = $Device.LastSuccessSync
#add the temporary object to the array
$stats += $m
}
}
#format and display
$stats | ft * -Autosize | Out-String -Width 10000 | out-file c:\_combinesList4.csv
This is an example of the result
Seinfeld, Jack jack HTC Radar 4G WP MSFT-WP/7.10.7720 12/8/2011 11:15:40 PM 12/23/2011 3:08:57 PM
Seinfeld, Jack jack HTC Radar 4G WP MSFT-WP/7.10.7720 12/8/2011 11:15:40 PM 12/23/2011 3:08:57 PM
Seinfeld, Jack jack HTC Radar 4G WP MSFT-WP/7.10.7720 12/8/2011 11:15:40 PM 12/23/2011 3:08:57 PM
Seinfeld, Jack jack HTC Radar 4G WP MSFT-WP/7.10.7720 12/8/2011 11:15:40 PM 12/23/2011 3:08:57 PM
However, my user jack seindfield have 4 different devices
[PS] C:\scripts>Get-ActiveSyncDeviceStatistics -mailbox jack |ft deviceid,deviceuseragent,lastsuccesssync
DeviceID DeviceUserAgent LastSuccessSync
-------- --------------- ---------------
ApplDLXG138JDFHW Apple-iPad2C1/812.1 2/4/2012 12:30:15 AM
Appl321200XTEDG Apple-iPhone2C1/901.334 2/2/2012 5:45:43 PM
Appl7R125RU1A4S Apple-iPhone3C1/901.405 1/10/2012 8:09:59 AM
362E208BF5DEFBB5237745260382060F MSFT-WP/7.10.7720 12/23/2011 3:08:57 PM
Why the script seems to be taking only the results from one device, and displaying the same thing 4 times ???
Help, i'm a complete newb with this kind of powershell reports.
Import-Module - Dependencies??
I just stood up a brand new Windows 2008 R2 VM for my test AD domain. I installed the Windows Powershell Feature but have run into a snag: the import-module cmdlet is unavailable. My execution policy is remote-signed but the cmdlet doesn't seem to exist. I've tried tab-complete, manually typing out the cmdlet name, but I get the following error:
I've researched to see if there's someone dependency on the cmdlet but haven't been able to find one. I also can't seem to find anyone having the same issue. Can anyone offer any insight as to why I might be getting this?
Edit: I used servermanagercmd.exe to uninstall and reinstall the powershell feature and I get the same result.
GUI Translator
Is there a why that I can see the command's a GUI runs through in a command line window?
HeadAche27
how to get format time as needed in vbs
i'm testing a vbs script for my study. and in this script i get the current time of the system by using method now()
but here comes a question. in different systems and different configuration the form of the system datetime may not be the same.
such as 2012-01-01 10:10:10
2012-1-1 10:10:10
2012-1-1 am 10:10:10
even 2012/1/1 10:10:10 or something else.
how can i format all this different form as the type of 2012-01-01 10:10:10 in the vbs script? thanks :)
programmatically modifying reg hive in WinPE
Hello all,
As part of an install on some machines here at work, I need to load a registry hive to the OS after installing it using imagex. This is all done in the WinPe environment . I know how to use regedit to load the additional changes to the reg hive (which is located in C:\Windows\System32\Config) using a created hive file or a reg file. I am wondering if someone knows how to do this programmatically in WinPe via maybe batch script or vbscript (my WinPe does have the WSH stuff enabled).
Note: I need to do this in WinPE because the reg keys that I am modifying are restricted in Win7 therefore I wont have the admin rights to do it within the OS when it loads.
VBScript DateDiff on DateLastModified
Hi Everyone,
I'm doing a little script to check whether certain files were updated within the last hour and then perform an action. Below is the script where all that appears is a messageBox that displays how many files were updated more than an hour ago. I have 2 files in the folder I specified and I keep getting 2 as an answer even if I've just updated the files.
If there are 3 files in the folder and 1 was updated 65 minutes ago and the other 2 were updated 30 minutes ago, the MessageBox must return 1
Dim fso, folder, files Dim strPath Set fso = CreateObject("Scripting.FileSystemObject") strPath = "C:/FileExtensions/" set folder = fso.GetFolder(strPath) set files = folder.Files CounterNum = 0 For each item in files If DateDiff("N",item.DateLastModified,Now()) > 60 Then CounterNum = CounterNum + 1 End If Next MsgBox CounterNumThanks,
J
powershell equivilent of reference object tag from wsf structure?
Im wondering what is the powershell equivilent of reference object tag in powershell? I was thinking about converting a script to powershell from vbscript and was wondering what the equivilent was.
Thanks jrv for the insite on powershell i will try converting it to powershell if the vb.net guys dont think of anything else i can try you havent thought of.
Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda
Add new property to WMI Win32_OperatingSystem class
Hi,
I have a requirement to add a property to the Win32_OperatingSystem WMI class, and can't find any information on how to do this - either by using a mof file or a VBScript. Can anyone help? I can find lots of information about adding properties if you are creating a new class - but nothing about modifying an existing class.
All I need to do is add a property called something like 'Company_Wallpaper' to the class and then set a boolean value of 'true'.
I can do it manually through WBEMTEST - but need to do this via a script or mof file update so that I can amend all PCs throughout our environment via an SCCM deployment.
File Permission change automaticaly
Dear All,
Today i have very unique issue, we have one file server containing lots of files as well as folder. now one user want that whenever he create the file in respective folder, it will automatic change to read-only after 48 hours. nobody can change or modify the contents in the files. these all files will be in same folder. we have 2003 std file server.
can somebody please help me..
Thanks
Manjeet Singh
Site i am Viewing has attached itself to (L) hand side of my screen and there is no X showing to close it
Change Outlook Signture when sending as a distribution group
Hello Everyone,
Is there a script to automatically change the signature in Outlook, when selecting to send from (send as) a distribution group? (Outlook 2010 - Exchange 2010)
Thank you,
Daniel
Logon Script
Need help getting Unexpected token '}' an expresstion or statment
I am working in the MOAC lab and have hit a Snag
getting Unexpected token '}' an expresstion or statment in statment
Import-CSV `c:\Project58members.csv'| foreach-object -process {Set mailbox -identity $_.Identity -managedfoldermailboxpolicy `Project58 Managed folder policy'} <<<<
any suggestions
Running if test from button in gui - does not finish and provide results
Hello,
When I run this script using a button in a GUI, it never stops thinking... and does not provide my results.
If I run this alone within powershell without GUI, it runs fine.
if ($testfail = Get-WmiObject -query ("Select * from Win32_NTLogEvent Where Logfile='Application'") | Select-Object @{n='TimeGenerated';e={[Management.ManagementDateTimeConverter]::ToDateTime($_.timeGenerated)}},` Message, EventCode | Where-Object { $_.message -like '*Activation context generation failed for "c:\program files\microsoft security client\MSESysprep.dll".*'}) { $AppLogSelection = $testfail | Select -first 10 $AppLogSelection } Else{ Write-host "Unable to locate error" -foregroundcolor "magenta" } I am running other if statements within the Gui using buttons and they all work ok, just not this one.
Michael
Logging Results of Remove-ADUser
I hope someone could provide some assistance with logging and the Remove-ADUser Powershell Cmd-Let. The script I have written takes in a list of users from a text file and deletes the user account. This works fine but I would like it to log the results of whether the command ran successfully or not for historical and auditing purposes. I can return error by using the -ErrorVariable (when not using the Trap cmdlet) but can not get it produce a result if it is successful as I can with Disable-ADObject and the PassThru parameter. I have also tried using Remove-ADObject, piping directly to a file using Out-File, and the Tee-Object cmdlet but get the same results. The script:
import-module activedirectory foreach ($srv in Get-Content userlist.txt) { #trap [ "Error with: " $svr ; continue ] #{ $test = Remove-ADUser $srv -ErrorAction SilentlyContinue -ErrorVariable Err $Err | Out-File output1.txt -append "" |out-File output1.txt -append #} } $test | export-csv output.txt -NoTypeInformation -ErrorAction SilentlyContinue -ErrorVariable Err $Err | out-file output1.txt -append
Bonus points if you provide assistance with getting the trap to display the errors in a text file, but not on the screen. Any help is greatly appreciated, but please be gentle, I am Powershell newbie ;-)
