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

PowerShell -> change NIC adapter binding order?

$
0
0

Windows 7 x86/x64 (PowerShell or VBScript)

Looking for a script that can change the network adapter binding order. Ideally, this will run immediately after sysprep, with no user interaction.  Would anyone know of a good method?


Diskpart, drive letter removal using a wildcard

$
0
0

I am trying to write a diskpart script to automatically set a drive letter to "F" the disk is always plugged into the same port, but anytime the computer reboots it assigns a different drive letter, but it never hands out the "F" letter to any other drives.

The problem is it assigns a different letter each and every time, so I need to use some type of wildcard for the drive letter, the volume number never changes, but unless you know the drive letter you can't change the letter, therefor I can't use a script to do this when the computer starts up.

logon scripts WIN 8

How to open the F12 key debugger in HTA like IE?

$
0
0

Press the F12 key on IE opens the built-in debugger, that's a wonderful feature.

Change the extended filename from .htm to .hta,  in another word, run the same program but use mshta.exe instead of IE then the F12 key doesn't open the debugger. Is there a switch to enable it, a different hotkey or interface to open it, or simply not supported?

If not supported, please .... I wish there's a plan.

Node-webkit already has it for long but for many automation goals HTA is still more suitable.

Send-mailmessage cmdlet not sending mail

$
0
0

hi

I am using send-mailmessage cmdlet in one scripts from my domain machine to send one attachment to my user id. I have added my IP on SMTP/Relay server also.

Send-mailmessage -from "user1 <user1@domain.com> -to "user2 <user2@domain.com>" -subject " Test Mail " -attachment " File details " -smtp <IP>

This cmdlet executes without any error but mail is not trigeer to respective user. Telnet to smtp server works from my machime on 25 port.

OS - Win 7 SP1 ; Powershell Ver - 2.0

Help me what need to check more.

How do I unblock files on Windows 8?

$
0
0
I've tried researching this already but all i was told was "run Unblock-File PowerShell 3.0 commandlet" ... "like this: Unblock-File .\php_manual_en.chm". I don't understand what that means. Can someone explain?

 

Script to find and remove video file in a domain

$
0
0

Good Morning every one,

I am new in using scripting for system administration and i am facing one challenge. In fact i am looking for a script that could help me in finding video files in my windows 2008R2 domain environment with most of the client as windows 7. The thing is that the share folder where all users store their home drive is getting saturated and i would like to find and remove all the video files to free more space.

Any idea on how to achieve that will be appreciated.

Thank you in advance for your time and advices.


OR

Connect-MsolService doesnt require proxy details??

$
0
0

Hi,

When i run the Connect-MsolService it just takes user-credentials and connects to office365.But the same case is not with Exchange-online, it need a proxy details or authentication.

May i know why is the connect-msolservice connecting without the proxy details? why we require proxy details for exchange-online?

I am running the cmdlets in a protected network, where proxy details are must to interact with the public websites. 

Thanks,

Satya


How can I encode a script file using the Microsoft Script Encoder?

$
0
0

Hi team,

How can I encode a script file using the Microsoft Script Encoder?

 

Thanks,


Doria

Batch File - Replace old version

$
0
0

I have a Word document that I have created which contains several macros. This file is copied by other employees into different folders on the file server for them to use.  I often make admentments to the master copy and have to email this to everyone asking them to replace their versions with the latest.  This often doesn't happen meaning they are using an old version which can cause issues.

What I am trying to do is create a batch file that I can run overnight that will search the file server (basically every folder and subfolder where the batch file is created - nothing higher) looking for an old version and replace it with a new version.  The file name contains the version.

I have been using the below but it does not seem to be working. 

for /F "tokens=*" %%P in ('dir /b /s "Menu v1.9.docm') do copy /Y .\"Menu v1.10.docm" "%%P"
@Pause

This is not something I have written myself as I don't normally write batch files.

Can anyone help?

vbscript - Error unsupported 16 bit - application

$
0
0

vbscript and 16 bit error

My vbscript so far had never a problem. And then suddenly (suspect windows updates) i had  a problem launching a simple vbscript that exectutes a external command in hidden mode on some computer running windows 7 64 bit.

I simple execute a batch file in hidden mode with the following vbscript hidden.vbs:

CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False

i launch: q:\bin\sgv\onlogin\hidden.vbs q:\bin\sgv\onlogin\onlogin.cmd

The script give me the error (german)

"Nicht unterstützte 16 bit - Anwendung
Das Programm bzw. die Funktion "\??c:\windows\system32\wscript.exe" kann aufgrund einer Inkompatibilität mit 64 Bit-Versionen von Windows nicht gestartet ... werden"

Translating in english:

unsupported 16 bit - app
the program or function \\??c:\windows\system32\wscript.exe can't be executed ... because of incompatibility with 64-bit versions

Any idea ?

script to show a count down timer in a message box.

$
0
0

Hi,

We are looking for a count down timer embedded in a message box.User will be having 2 options.

1.User can click on the OK button in the message box (timer ends) and continue with the next step.

2.Timer will be counting for 10 minutes. After that it will execute the next step automatically.

Can we achieve this through a vbscript..Please advice.

 


Thanks and regards Aneesh Philip

Recursively search folders, export to excel all sub-folders. All folders containing ReadMe.txt export contents.

$
0
0

I have a bunch of VBScripts that I created using help from this forum and other forums.  These scripts are for fixing Windows problems, installing software and setting configuration settings. Each script is in a separate folder. Some of the script folders contain a file called ReadMe.txt that contains info about the script and what it does.  I am trying to document all my fixes so I can share them with coworkers, friends and anyone who needs help. I struggle with the "recursive" feature in VBScript. I found the Scripting Guy's article on recursive searching and found another article from another website that works really well for listing all folders and subfolders to a CSV file.  I'm having trouble adapting the script.  After it exports the folder list to the CSV, I need it to go back through the list and for every folder that contains the ReadMe.txt, export it's contents to the row for the specific folder that contains the file.

I've tried several modifications of this script but all my attempts cause the script to Not export the file list.  I cannot get past this problem. Until I do that I cannot even focus on the exporting the contents of the ReadMe.txt file to the CSV file.

Here is the code I have

Dim objFSO
Dim ObjOutFile

'Creating File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Create an output file
Set ObjOutFile = objFSO.CreateTextFile("OutputFiles.csv")

'Writing CSV headers
ObjOutFile.WriteLine("Type,File Name,File Path")

'Call the GetFile function to get all files
GetFiles("H:\0-Fixes")

'Close the output file
ObjOutFile.Close

WScript.Echo("Completed")

Function GetFiles(FolderName)
On Error Resume Next

Dim ObjFolder
Dim ObjSubFolders
Dim ObjSubFolder
Dim ObjFiles
Dim ObjFile

Set ObjFolder = objFSO.GetFolder(FolderName)
Set ObjFiles = ObjFolder.Files

'Write all files to output files
For Each ObjFile In ObjFiles
ObjOutFile.WriteLine("File," & ObjFile.Name & "," & ObjFile.Path)
Next

'Getting all subfolders
Set ObjSubFolders = ObjFolder.SubFolders

For Each ObjFolder In ObjSubFolders
'Writing SubFolder Name and Path
ObjOutFile.WriteLine("Folder," & ObjFolder.Name & "," & ObjFolder.Path)

'Getting all Files from subfolder
GetFiles(ObjFolder.Path)
Next

End Function


 

Helpful nice guy

VBScript and SMO

$
0
0

I've have a vbscript that utilizes sql-dmo and accesses sql 2005 and sql2008 r2(with back ward compatability).  I now have a sql 2012 server where this script no longer works.  I've attempted to change the sql-dmo to smo per the documentation, but am getting an error right from the start. 

Set objSqlServer = CreateObject("Microsoft.SQLServer.Management.SMO.Server")  returns "Microsoft VBScript runtime error: ActiveX component can't create object: 'Microsoft.SQLServer.Management.SMO.Server'"

Does this not work using vbscript?  If not, what is my best course of action.

thanks in advance for any help on this.

Last Run Result Email Alert from Scheduled Task

$
0
0

Hi All,

Ive a newly require need to move 3 files from a local server to a remote server via FTP each evening.

Local server is a Server 2008 box.

I have setup WinSCP to transfer the files over successfully via a Scheduled Task

Now i need alerting!!

Ive setup the email function in Task Scheduler and it does send me an email but a pretty pointless one at that as it doesn't tell you the Last Run Result status code.

So all i know is the job has run but i don't know if with errors etc.

Each morning ill have to FTP to the remote server and manually check the time and date stamps myself to make sure the copy was successful.

Ive checked the event log and it writes an Event ID 201 to the Task Scheduler Event Log and that has all the info i need in the description, but i cant attach that event to my scheduled task as there are lots of 201's for all different scheduled tasks that run that by the OS.

Anybody know how i can get the last Run Result in the body of the email or the subject line at least - so i know if it is a 0x0 the job has been successul and anything other than 0x0 that there has been a problem.

Any suggestions?

Thanks in advance.

PowerShell: How do I reliably set the IP address on an interface when the interface is not connected ?

$
0
0

Hello all,

I am in a bit of a bind - no pun intended.  I would like to know how to reliable set the persistent IP address of an interface that may be disconnected when the address is set.  I can set an address and it will be stored in the ActiveStore but that does not really help if I need it next time I reboot.  I have tried using netsh and WMI but they don't seem to create a persistent address on the disconnected interface.  Now if I us ncpa.cpl I can do it all day long so it must be possible. In fact if I do it that way the registry settings change. So, I figured I would go that route (modifying the registry) but, alas, that does not work either - upon reboot the address shown in the interface properties show a blank IP address, gateway, and netmask.  It is interesting that it is using a static address though. 

Thanks for your help

Robert


Robert Thompson


extract certain account from log file

$
0
0

i have one ftp log file which includes user accounts and activities.
I need to pull user with failed activities.  I can search in the
log file.  Is there a way to extract several user accounts from the log file?

Thank you!

My computer can see my network drives, but Powershell can't

$
0
0

Having a bit of a strange issue with Powershell today, I went to open a script I had worked on last night and Powershell is telling me that it can't find my H: drive (my personal drive here at work) despite the fact that I'm browsing it just fine with my computer.

Screenshot with error below - note that the image I uploaded is on that same H: drive, so it seems to be just Powershell!


zarberg@gmail.com

VBScript - Deleting an array element

$
0
0

I am trying to write a script that checks for a specific value in the registry and then deletes that value.  In my case, the value is only a subset of the comma separated text within the key value.

I am trying to treat the string "(example: "vmhgfs,RDPNP,LanmanWorkstation,webclient" as an array bySPLITing into multiple elements and then setting the unwanted array element toEMPTY.  I then want to write the value back as a string but without the element I'm removing (Example:"RDPNP,LanmanWorkstation,webclient".

 The script properly reads the value from the registry and the SPLIT function works to separate the elements.  When I try to JOIN the elements into a new string, I still get a ',' (comma) delimiter for the element I've removed (example:,RDPNP,LanmanWorkstation,webclient).  

 How do I do this so that the comma is not created?  Is there a better way to do this?  I know I could parse the text string and remove the comma but that seems like sloppy coding and the element I'm removing is not always in the same place.

 

'
' Purpose:	Check for VMWare Tools Shared Folders Provider

Dim strRegArray, strRegValue
Dim I
Set WshShell = CreateObject( "WScript.Shell" ) 'Bind to the Registry provider

strRegValue = WshShell.RegRead( "HKLM\System\CurrentControlSet\Control\NetworkProvider\Order\ProviderOrder" )

strRegArray = Split(strRegValue,",")	'Copy Registry values into an Array 

For I = 0 To UBound (strRegArray)

	If strRegArray(I) = "vmhgfs" Then 
		strRegArray(I) = Empty
	End If
	strNewArray = Join(strRegArray, ",")


Next
	 WScript.Echo strNewArray	

 


Change permissions of "Mailbox Rights" using Script.

$
0
0

I'm using the script located at http://support.microsoft.com/kb/310866 to change the permissions of "Mailbox Rights" located on the user properties, Exchange Advanced tab.However, this works by specifying the DN for each mailbox that I want Change.I need help to create a script, or edit it to modify the permissions of multiple users in the field since the script from Microsoft so I may change by a user at a time in the line of Script:

sUserADsPath = "LDAP: / / ServerName / cn = User1, CN = Users, DC = DomainName, DC = com"

It is possible to insert in the variable "sUserADsPath" multiple paths DN?or is there another way to do this? I am using Exchange 2003.

Maybe a Loop that reads a .csv file of something like that.

Thank you.

Viewing all 15028 articles
Browse latest View live


Latest Images

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