Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all 15028 articles
Browse latest View live

How to Change the Screen Saver Settings to Mystify in Windows 7 using vbscript?

$
0
0

HI All,

How to Change the  Screen Saver Settings to Mystify in Windows 7 using vbscript?

Thanks

Divakar


New-ADuser error: The server is unwilling to process the request

$
0
0

Hi

I am attempting to add new users in bulk to AD using the below PowerShell script:

Import-Module ActiveDirectory
Import-Csv "C:\users1.csv" | New-ADuser -PasswordNeverExpires $true -AccountPassword (ConvertTo-SecureString "Pass1234" -AsPlainText -Force) -Enabled $True -Server <AD-servername>

Note: <AD-servername> is replaced by the actual name of the Domain Controller

The contents of the CSV are (lines 1 & 2 only are provided below):

Name,Type,SamAccountName,GivenName,Surname,DisplayName,Description,EmailAddress,Company,StreetAddress,State,PostalCode,City,Country,Organization,Path,UserPrincipalName
DOE John,User,DJohn,John,DOE,John DOE,Sales Supervisor ,DJohn@domain.com,Corp Europe,16 Street Add,MA,1234,Boston,USA,Corp,"OU=Users,OU=warehouse01 - boston - ma,OU=Massachussetts,DC=domain,DC=net",DJohn@domain.com

When executing the script I get the following error:

New-ADuser : The server is unwilling to process the request
At C:\Users.ps1:2 char:29
+ Import-Csv "C:\users ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (CN=Djohn...et,DC=domain,DC=net:String) [New-ADUser], ADException
    + FullyQualifiedErrorId : The server is unwilling to process the request,Microsoft.ActiveDirectory.Management.Commands.NewADUser

After investigation on different forums (e.g: http://www.manageengine.com/products/ad-manager/help/misc/troubleshooting_tips.html#admgmt_usermodificatio_80072035 or http://social.technet.microsoft.com/Forums/scriptcenter/en-US/ae10b881-ae5b-4382-b033-47174e5acd8a/error-with-newaduser-command?forum=winserverpowershell) I have verified:

  1. that the OU Path is spelled correctly
  2. that no other user with the same samaccountname exists in AD
  3. that the pipe from import-csv to new-aduser works correctly
  4. that the import-csv command imports correctly (see result below): 

Name              : DOE John
Type              : User
SamAccountName    : DJohn
GivenName         : John
Surname           : DOE
DisplayName       : John DOE
Description       : Sales Supervisor
EmailAddress      : DJohn@domain.com
Company           : Corp Europe
StreetAddress     : 16 Street Add
State             : MA
PostalCode        : 1234
City              : Boston
Country           : USA
Organization      : Corp
Path              : OU=Users,OU=warehouse01 - boston - ma,OU=Massachussetts,DC=domain,DC=net
UserPrincipalName : Djohn@domain.com

PS: the OU Users is the child OU of warehouse01 - boston - ma which is itself a child of Massachussetts

PPS: Domain.com is the external dns domain name.  Domain.net is the local dns domain name. All our users have this format. 

==

What is this error? what am i doing wrong?

Thanks,

Karim

find users that changed password in last 180 days

$
0
0

how can i find users in the domain that have not changed their passwords in the last 180days?

Need to run Icacls command on multiple servers

$
0
0

Hi

I have a text file with the list of servers and it is called servers.txt and I want to run the below command on all the drives on all the servers in that text file. 

icacls folder1 /T /Grant "domain\user1:F"

Can you please give me a sample Powershell script to do it

thanks


scripting to install executable drivers

$
0
0

I have a script working fine with msi but it doesn't work with exe installer. Need professional advise and  help 

The first part of script create a folder and unzip the zipped folder which contain setup.exe

But the rest part of script running 3 installers didn't work , just hanging. If I manually run each installer at PS console, it is ok but I want them to run in sequence , silently and remotely with GPO that has already enabled PSRemoting. GPO also set up to  load the files (unzipped)in local C:\test folder:

# install msi and exe Installer
$installer = 'c:\test'
$exe = @('$installer\dellDriver\dellver1.02\setup','$installer\dellDriver\firmDriver_Win7_64Bit')
$msi = @('$installed\Installer_Win7')
  
  #foreach ($exefile in $exe) 

{
start-process -FilePath "c:\test\dellDriver\dellver1.02\\Setup.exe" /s
Start-Process -FilePath "c:\test\dellDriver\firmDriver_Win7_64Bit.exe" /s
Start-Sleep 120
Start-Process -FilePath "c:\test\Installer_Win7.msi" -ArgumentList "/qn" -wait
}

re-run vbs script with time interval.

$
0
0
i have some vbs script and i want it to run automatically after each 10minutes. (No task scheduling). any line of code outside/inside same script which runs wanted vbs file with 10min interval.Thanks

record each keystroke

$
0
0
is there any vbs/batch code to record and store each key stroke hit by user?i don't want to use softwares.

Installing printers drivers from power shell on win client

$
0
0

Hi,

I am using a powershell script to install printer drivers from our print server. I am getting a error.

Sript :-

(New-Object -ComObject WScript.Network).AddWindowsPrinterConnection("\\ptprint\pg1-b")

(New-Object -ComObject WScript.Network).SetDefaultPrinter('\\ptprint\pg1-b')

PTPRINT is our print server and pg1-b is printer shared name.

Error : -

Exception calling "AddWindowsPrinterConnection" with "1" argument(s): "The I/O operation has been aborted because of
either a thread exit or an application request. (Exception from HRESULT: 0x800703E3)"
At C:\Users\amitkumar_patil\Desktop\addprinter.ps1:4 char:1
+ (New-Object -ComObject WScript.Network).AddWindowsPrinterConnection("\\ptprint\p ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ComMethodTargetInvocation

Exception calling "SetDefaultPrinter" with "1" argument(s): "There is no printer called "\\ptprint\pg1-b"."
At C:\Users\amitkumar_patil\Desktop\addprinter.ps1:10 char:1
+ (New-Object -ComObject WScript.Network).SetDefaultPrinter('\\ptprint\pg1-b')
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ComMethodTargetInvocation

1. How to solve this ?

2. Is my way to install drivers is incorrect via power shell ?


Find name of last user to have changed any AD user password

$
0
0

I am curious to know if there is a way to get the username of the person that last changed a password (not necessarily his own).

For example: A regular user (say Gary) forgot his password and calls an admin whose username is ADM_JDOE and who has the right to reset passwords.  How can I find out that the last password change was made by ADM_JDOE (or any other admin) and not by Gary?

Thanks,

SK

Move Text content to Excel

$
0
0

HI team,

I have a number of text file in a folder. each file gives information like hostname, OS, username, service pack etc. about individual machine. Example of one of the file

--------------------------------------------------------------------------------------

Hostname = desktop12456

OS = Windows 7

username = Joe B

--------------------------------------------------------------------------------------

I want to collect this information of all text files in excel sheet as

-------------------------------------------------------------

    Hostname          OS          Username

desktop12346       Win 7          Joe B

laptop123456        win 8          mick s

.

---------------------------------------------------------------

Could please help give a idea which cmdlets can I use in writing a script ?

http://www.codecademy.com/forum_questions/539cb3d9548c357fe1003136

$
0
0
http://www.codecademy.com/forum_questions/539cb3d9548c357fe1003136

VBScript Icacls

$
0
0

Dear,

I dont know what wrong with below script its not sccuessfully running


OptionExplicit
Dim Obj, intRunError, strHomeFolder
Set Obj = wscript.createobject("wscript.shell") 

strHomeFolder = "C:\Program Files\Temp\"

'intRunError = Obj.run ("%COMSPEC% /c Echo Y| cacls " & strHomeFolder & " /c /g users:M ", 2, True)
Obj.Run"icacls strHomeFolder /grant:r users:(OI)M"



Support@Mytechnet.me

Delete content of all users Download folders

$
0
0

Hi ,

I checked in the forum for that but did not find anything that can suits my issue.

I need to delete all the content of all users download folder every night .

I tried this %userprofile%\Downloads | where {($_.LastWriteTime).AddDays(1) -lt (get-date)} | remove-item -force -recurse

but  it does not help.

Could you please help me or put me in the right direction .

Thanks

AGYL

Start Application in Background

$
0
0

Hi,

Is there a way to start a programm in the background?

I want to run a VirtualBox in Headless mode without opening any window.

With a C#.Net Programm I archived it like this:

  myProcess.StartInfo.WorkingDirectory = @"C:\Program Files\Oracle\VirtualBox\";  myProcess.StartInfo.FileName = @"C:\Program Files\Oracle\VirtualBox\VBoxHeadless.exe";  myProcess.StartInfo.Arguments = string.Format("-s {0} -v on", args[0]); myProcess.StartInfo.CreateNoWindow = true;  myProcess.StartInfo.UseShellExecute = false; myProcess.Start();

Now I would like to do it with powershell, as I thought that it also should work as it is also .Net able ...

I used the Start-Process comand but I does not work.
I tried some combinations like this:

$str = @("-s","vmBox","-v","on");
Start-Process -FilePath "C:\Program Files\Oracle\VirtualBox\VBoxHeadless.exe" -ArgumentList $str -NoNewWindow -WorkingDirectory "C:\Program Files\Oracle\VirtualBox\"

But doing so, the program occupies the current powershell console and does not continue running when I close the terminal.

Is there a way to do so?


http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/3030821-allow-connecting-to-test-controller-using-differen <-- Vote for connecting with any user to Test Contrtoller


adding PDF options to a script

$
0
0

Hello everyone,

I use a powershell script (provided in the scripting guy blog and slightly modified by myself) to convert all .rtf files in a folder to pdf:

$wdFormatPDF = 17
$word = New-Object -ComObject word.application
$word.visible = $false
$folderpath = "C:\Users\xxx\Desktop\powershelltest\*"
$fileTypes = "*.rtf"
Get-ChildItem -path $folderpath -include $fileTypes |
foreach-object `
{
 $path = ($_.fullname).substring(0,($_.FullName).lastindexOf("."))
 $doc = $word.documents.open($_.fullname)
 $doc.saveas([ref] $path, [ref]$wdFormatPDF)
 $doc.close()
}
$word.Quit()
Exit

My question is this: How do I specify options for the created PDF docs?

I need the created PDFs to have these characteristics:

  • Set the “Initial Page layout” to “Bookmarks Panel and Page”
  • Must be saved as PDF Version 1.4 (acrobat 5.x compatible)
  • Enable fast web view
  • Enable bookmarks to have longer lengths than 40 characters (by default it seems the resultant PDF has 40 character limit on bookmarks, my .rtf files use embedded tc links for bookmarks that are much longer)
  • Not be PDF/A (seems to be default)

Any hints and pointers are much appreciated as I am very inexperienced with powershell and could not find anything helpful in my searches.

Kind regards,
Tiaan


Rename files using text or excel file

$
0
0
I am trying to find out how to rename files on my pc using the names stored in a text document
eg. the file on the pc is called "C07_08.dat"
the text file has the following line "3am Eternal         KLF         03:15 121 BMG         C07.08"
i want to change the name of the file "C07_08.dat" to "3am Eternal.mpeg"
What I would like is a batch file or program or something that will see the text "C07.08" and find the corresponding file "C07_08.dat" and rename it "3am Eternal.mpeg"
I have managed to create a excel document that has the information in four separate columns
Column A has the name of the file I want to use (ie. 3am Eternal) Column B & C have unneeded information and Column D has the file reference (ie. C07.08)
 
I was told that Python or Visual basic could do this so I downloaded them but I have no experience with this so im lost as to what to do, I have over 1800 of these files so doing it file by file will take quite a while.
I have included a sample of the text file for reference if that helps
3am Eternal          KLF           03:15 121 BMG     C07.08
4 In The Morning       Gwen Stefani       04:22 092 UMA     HD1.10
4 Minutes           Madonna ft J Timberlake 04:04 113 WAR     HE3.05
5 6 7 8            Steps          03:24 000 BMG     C48.03
5678             Steps          03:23 140 MUS     H16.02
6 Of 1 Thing         Craig David       03:15 116 WAR     HE2.11
60 MPH            New Order        03:51 125 WAR     N57.11
7 Days            Craig David       04:30 084 SHO     N41.16
7 Things           Miley Cyrus       03:29 107 EMI     HE7.09
99 Luft Balloons       Nena           03:58 095 WAR     C27.10
99 Times           Kate Voegele       03:27 112 UMA     HG6.07
A Girl Like You        Edwyn Collins      03:47 126 MDS     R06.08
A Little Bit         Pandora         03:35 132 UMA     H23.01
A Little Less Conversation  Elvis VS JXL       03:02 115 BMG     H68.03
A Matter Of Trust       Billy Joel        04:00 110 SON     C59.11
A New Day Has Come      Celine Dion       04:20 092 SON     H65.20
A Woman Like You       Mondo Rock        04:03 169 MUS     R06.01
About You Now         Sugababes        03:32 083 UMA     HD5.08
Absolutely Everybody     Vanessa Amorosi     03:52 124 TRA     H40.06
Absolutely Fabulous      Pet Shop Boys      03:45 132 EMI     C15.02
Accidentally In Love     Counting Crows      03:08 138 UMA     H94.05
According To You       Orianthi         03:18 066 UMA     HG4.12
Achy Breaky Heart       Billy Ray Cyrus     03:55 122 SON     K11.02

Insert SQL table from powershell to SQL 2000

$
0
0

Hey guys,

           Im far from a Powershell guru and DEFINITELY not a SQL guy. With that being said, I'm trying to write a SQL table(2000) from a powershell script I have written. The script is using the FileSystemWatcher to write any new files that have a .tif file extension to a SQL table.

Obviously, This is not working. Here's my insert code.

$conn=New-ObjectSystem.Data.SqlClient.SqlConnection("Data Source=$SQLServerName; Initial Catalog=$SQLDatabase; Integrated Security=TRUE")

     

$conn.Open()

     

$insert_stmt="INSERT INTO in_cofa_pvs (in_item_key, in_lot_key, imgfileName, in_cofa_crtdt) VALUES ('$item','$lot','$name','$timestamp')"


     

$cmd=$conn.CreateCommand()

     

$cmd.CommandText=$insert_stmt


     

$cmd.ExecuteNonQuery()

     

$conn.Close()

I guess I have two questions. 1 is my code looking correct ? All the variables are defined in code prior. 2 can I even use Powershell to insert tables into SQL 2000 ? and 3 if question 1 is YES and 2 is YES what the heck am I doing wrong here ?

Is there a way that I can log my SQL attempts to see failure/success ? Obviously the first is going to be the case. But when I have it working I would like to see if either is true.

Thanks Guys

Rich


Rich Thompson

WSUS products and classifications

$
0
0

Hi,

 Does anyone have a powershell script to list the products and classifications enabled on a wsus server?

Any assistance on this would be greatly appreciated.


Rick

Move mail from Inbox to subfolder with Exchange Web Services 2.0 and Powershell

$
0
0

Hi

I have created a script (With help from Google and some blogs :-)) that basically does the following:
1. Finds all mails with attachments
2. Saves the attachment
 2.1 If it's a .ZIP file, the file is extracted
3. Prints the attachments
4. Moves the file to a subfolder called Archive (This part doesn't work

The steps from 1 to 3 is working fine, but the part about moving the items to the subfolder it fails.

I have tested it with my own username and it's working as expected, but when I run the script in production with the service account I have created with impersonation rights it fails.
As far as I can see the problem is that the service account can't get the ID of the subfolder. I use the following code:

$FolderName = "Archive"
$oFolder = new-object Microsoft.Exchange.WebServices.Data.Folder($EWSService)
$oFolder.DisplayName = $FolderName

#Define Folder View really only want to return one object
$fvFolderView = new-object Microsoft.Exchange.WebServices.Data.FolderView(1)

#Define a Search folder that is going to do a search based on the DisplayName of the folder
$SfSearchFilter = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.FolderSchema]::DisplayName,$FolderName)

#Do the Search
$findFolderResults = $EWSService.FindFolders($InboxID,$SfSearchFilter,$fvFolderView)

If ($findFolderResults.TotalCount -ne 0)
{	
	$DestID = $findFolderResults.ID
	$Email.Move($DestID) | Out-Null
}

The "$findFolderResults.TotalCount" actually returns 1 if the folder is present but "$findFolderResults.ID" is empty, and therefor the "$Email.Move($DestID)" fails.

Any ideas?

Lasse


/Lasse

Update vbscripts that copy files to sharepoint via DAV to use powershell instead.

$
0
0
Update vbscripts that copy files to sharepoint via DAV to use powershell instead.
Viewing all 15028 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>