Hi,
May I know how to measure the boot up time (Coldboot) for 5 times using vbscript?
Hi,
May I know how to measure the boot up time (Coldboot) for 5 times using vbscript?
Hi all,
I have a VBS function (IsMember) to check whether a user is a member of a group or not - The domain, username and group name are passed in when the function is called... My dilemma is that it works fine in Windows 7/8/Server 2008 R2/2012 R2 etc. but fails when run on XP/Server 2003 with the fairly generic error of 0x80005008 at source (null). I'm wondering if it could be something syntax related with my query? Or if there is perhaps a component I am trying to reference that doesn't exist in XP?
Here's the function;
IsMember "domain", "userDN", "group" Function IsMember(Domain, User, Group) Dim oConnect, oRecordSet, oGroup Set oConnect = CreateObject("ADODB.Connection") oConnect.Open = "Provider=ADsDSOObject" Set oRecordSet = oConnect.Execute("SELECT AdsPath FROM 'LDAP://" & Domain & "' WHERE cn='" & Group & "'") Set oGroup = GetObject(oRecordSet("AdsPath")) If (oGroup.IsMember("LDAP://" & User)) Then IsMember = True Else IsMember = False End If oConnect.Close Set oConnect = Nothing Set oGroup = Nothing Set oRecordSet = Nothing End Function
If anyone has any suggestions or ideas as to where I might be going wrong I'd be very grateful.
James
I'm probably overthinking this issue, but I'm a SQL guy, not a powershell guy.
We have several users who's office location was populated in the "Office" field of AD. (physicalDeliveryOfficeName)
SOME users have the correct info (i.e.: Corporate, or Building C) while others have the city state.
I can get the users I want to change with -Filter {physicalDeliveryOfficeName -like "*,*"}, but how do I copy those users' info from that field to the actual city and state fields? (Stripping the comma, and separating the city/state)
Thank you
Hi,
Can VBscript able to measure timing for multiple files transfer using WinActivate or other option?
Example:
copy C:\Single 3GB file to D:\
copy C:\Single 5GB file to D:\
I am trying to automate the rollout of PC's ar my location. I have sysprepped a machine and imaged it with all that we need and after we deploy a machine we use a corporate provided script to join it to the domain. Post domain add I have another script that we run that firther sets up the machine. One of the tasks I am trying to accomplish is adding our local it security group to the PC's local administrators group. I have the following line in cmd file:
net localgroup administrators domain/local security group /add
This does not work and it appears to be because of the spaces in the group name (which is controlled by corporate and cannot be changed to something without spaces). I have tried encapsulating the group name in quotes, the domain plus the groupname in quotes and defining the while string as a variable and passing the variable to the command, but it always fails.
This is on Windows 7 enterprise x64. If I try to add the group via the gui (computer management) it works great so I know it is possible. Any help would be much appreciated.
I have a group of groups that I am trying to delete all of the users from. It happens that some of the users are in other domains than that of the groups. I have tried both the MS and the Quest versions of Remove-ADGroupMember. I have also read many posts but have yet to find someone who has actually been able to make it work.
It appears to me that the Remove-ADGroupMember function will only recognize users in the default domain. Has anyone been able to find a way around this?
Thanks. SB
Hello... I have a text file which is in this format:
#Time; SampleNum; SampleId; Moisture; Solids; Weight; Water; Amplitude; T2; FreqDiff
23-06-2014 07:28:01; 2655; trial; 58.0; 42.0; 242.4; 140.7; 1581.7; 1579.0; -25.1
I would like to run a batch file to open this txt (Mr.Result.txt) file and output a new file(Mr.Result_Output.txt) in this format:(no space between the SampleNum and SampleID... could not remove it when pasting)
Time=23-06-2014 07:28:01
SampleNum=2655
SampleId=trial
Moisture=58.0
Solids=42.0
Weight=242.4
Water=140.7
Amplitude=1581.7
T2=1579.0
FreqDiff=-25.1
I use this format to process the file to a SQL table. But am having difficulty with Batch file code.
Thanks in advance for your help.
Phoebe
~pt~
Hi Folks,
Relatively new to PowerShell and am most of the way through Ed Wilson's 'First Steps' book. I'm attempting to use Get-CimInstance; I expect I'm doing something that's very blatantly wrong.
I've used Get-ADComputer to get several computer objects which I've placed into an array called $itcomputers. I'd like to see the InstallDate from win32_bios for all of these computers. When typing in the names manually, it works fine, but when it's supplied with the variable to -ComputerName I'm shown an error.
Even changing the objects to string using Out-String doesn't seem to work. Do you have any thoughts on what I'm doing wrong? I expect perhaps I'm just simply going the wrong way about getting this cimcmdlet to get the information from an array. In regards to the below script, $itcomputers is populated at this stage already.
foreach ($computer in $itcomputers) { Get-CimInstance -ClassName win32_bios -Property InstallDate -ComputerName $computer }
The error says the below, with the Distinguished Name as the value:
Get-CimInstance : WS-Management could not connect to the specified destination:
Many thanks.
All,
I have inherited a legacy web site and have encountered a problem that I can't get figure out:
The program structure is as follows:
1. Execute a SQL Server Stored proc and create XML from the result set
2. If a condition is met, exceute a second stored proc and hydrate the XML from step one with some more tags
3. return the XML is the response
Step 1 happens without problems, but when the condition is met the execution halts as soon as I try to do anything with the Result Set. For instance setRS.ActiveConnection = nothing or do until CustodianRS.EOF both halt execution. and I end up with an empty Response.
Here is the offending code:
if len(trim(strTradingArea)) = 4 then
dim CustodianCN
dim CustodianCMD
dim CustodianRS
dim node
set CustodianCN = server.CreateObject("ADODB.Connection")
CustodianCN.CursorLocation = adUseClient
CustodianCN.Open Application("PANORAMA_SACDETAILS")
set CustodianCMD = server.CreateObject("ADODB.Command")
with CustodianCMD
set .ActiveConnection = CustodianCN
.CommandType = adCmdStoredProc
.CommandTimeout = 300
.CommandText = "p_SACGetAccountCustodiansByTradingArea"
.Parameters("@TradingArea").Value = strTradingArea
set CustodianRS = .Execute
end with
'set CustodianRS.ActiveConnection = nothing
CustodianRS.Sort = "Custodian"
do until CustodianRS.EOF
set node = responseXML.createElement("custodian")
node.setAttribute "id",trim(CustodianRS.Collect("Custodian") & "")
node.setAttribute "parent",trim(CustodianRS.Collect("Parent") & "")
responseXML.firstChild.appendChild(node)
CustodianRS.MoveNext
loop
end if
Does anyone have any suggestions? Any help would be much appreciated, I have already spent a considerable amount of time on this.
Thanks!
Hi team,
I was trying to download a file from a location on the internet after giving the credentials to log into the website. I am getting the download prompt for saving the file but I want to automate it and save the file locally. Is there a way I can get the prompt clicked and save it locally? I dont want to use Webclient.DownloadFile as it gives me proxy authentication error and my employer would not allow that. I want to directly click the download prompt and save it locally. Is there a way to do that in Powershell?
The download prompt has "Open","Save" (which further has "Save" and "Save As" options) and "Cancel" Button which we all come across when we try to download a file.
Help is truly appreciated.
Hello All,
Not much of a script writer. I am giving it a shot. My issue is that I need to run a application update across our network and I am trying to do it with as little hands on as possible. So I was planning to push a GPO with a power shell script in it to run the program with elevated privileges.
Little background:
We are running on a domain and end users do not have admin rights.
The application is stored on a share on our network that is open to all domain users.
The installer user name and password is a temp one and will only be valid for the 30 min window when everyone logs in at the beginning of the day.
So this is what I have so far.
$username = "USER" $password = "PASSWORD" $credentials = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force)) Start-Process PSQLv11Patch_Client_x86.msp -Credential ($credentials) -WorkingDirectory \\Server\Folder\Folder1\Folder2\filder3\PSQLv11sp3_x32\
But for some reason I keep getting :
Start-Process : This command cannot be run due to the error: The system cannot find the file specified.
At line:10 char:1
+ Start-Process PSQLv11Patch_Client_x86.msp -Credential ($credentials) -WorkingDir ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
Any help you could give would be great.
Thanks,
jdfmonkey
Below script produces a report and mail sent successfully, but no disk space details in the body, only table with headings.
On Error Resume Next
Const ForAppending = 8
Const HARD_DISK = 3
Const ForReading = 1
'Declaring the variables
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set SrvList = objFSO.OpenTextFile("c:\temp\sl.txt", ForReading)
Set ReportFile = objFSO.CreateTextFile ("c:\temp\diskspace.htm")
ReportFile.Close
Set ReportFile = objFSO.OpenTextFile ("c:\temp\diskspace.htm", 2)
ReportFile.writeline("<html>")
ReportFile.writeline("<head>")
ReportFile.writeline("<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>")
ReportFile.writeline("<title>" & "DISKSPACE Report</title>")
ReportFile.writeline("<style type='text/css'>")
ReportFile.writeline("<!--")
ReportFile.writeline("td {")
ReportFile.writeline("font-family: Tahoma;")
ReportFile.writeline("font-size: 11px;")
ReportFile.writeline("border-top: 1px solid #999999;")
ReportFile.writeline("border-right: 1px solid #999999;")
ReportFile.writeline("border-bottom: 1px solid #999999;")
ReportFile.writeline("border-left: 1px solid #999999;")
ReportFile.writeline("padding-top: 0px;")
ReportFile.writeline("padding-right: 0px;")
ReportFile.writeline("padding-bottom: 0px;")
ReportFile.writeline("padding-left: 0px;")
ReportFile.writeline("}")
ReportFile.writeline("body {")
ReportFile.writeline("margin-left: 5px;")
ReportFile.writeline("margin-top: 5px;")
ReportFile.writeline("margin-right: 0px;")
ReportFile.writeline("margin-bottom: 10px;")
ReportFile.writeline("")
ReportFile.writeline("table {")
ReportFile.writeline("border: thin solid #000000;")
ReportFile.writeline("}")
ReportFile.writeline("-->")
ReportFile.writeline("</style>")
ReportFile.writeline("</head>")
ReportFile.writeline("<body>")
ReportFile.writeline("<table width='100%'>")
ReportFile.writeline("<tr bgcolor='#CCCCCC'>")
ReportFile.writeline("<td colspan='7' height='25' align='center'>")
ReportFile.writeline("<font face='tahoma' color='#003399' size='2'><strong>DISKSPACE Report</strong></font>")
ReportFile.writeline("</td>")
ReportFile.writeline("</tr>")
ReportFile.writeline("</table>")
Do Until SrvList.AtEndOfStream
StrComputer = SrvList.Readline
ReportFile.writeline("<table width='100%'><tbody>")
ReportFile.writeline("<tr bgcolor='#CCCCCC'>")
ReportFile.writeline("<td width='100%' align='center' colSpan=6><font face='tahoma' color='#003399' size='2'><strong>" & StrComputer & "</strong></font></td>")
ReportFile.writeline("</tr>")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery("Select * from Win32_Volume")
ReportFile.writeline("<tr bgcolor=#CCCCCC>")
ReportFile.writeline("<td width='10%' align='center'>Drive / Mount</td>")
ReportFile.writeline("<td width='50%' align='center'>Drive Label</td>")
ReportFile.writeline("<td width='10%' align='center'>Total Capacity (in GB)</td>")
ReportFile.writeline("<td width='10%' align='center'>Used Capacity (in GB)</td>")
ReportFile.writeline("<td width='10%' align='center'>Free Space (in GB)</td>")
ReportFile.writeline("<td width='10%' align='center'>Freespace %</td>")
ReportFile.writeline("</tr>")
'Starting the loop to gather values from all Hard Drives
For Each objDisk in colDisks
'Delcaring the Variables
TotSpace=Round(((objDisk.Capacity)/1073741824),2)
FrSpace=Round(objDisk.FreeSpace/1073741824,2)
FrPercent=Round((FrSpace / TotSpace)*100,0)
UsSpace=Round((TotSpace - FrSpace),2)
Drv=objDisk.DriveLetter
VolName=objDisk.Label
If Len(VolName) > 3 then
If FrPercent > 20 Then
ReportFile.WriteLine "<tr><td align=left>" & Drv & "</td><td align=left>" & VolName & "</td><td align=center>" & TotSpace & "</td><td
align=center>" & UsSpace & "</td><td align=center>" & FrSpace & "</td><td align=center>" & FrPercent & "%" &"</td></tr>"
ElseIf FrPercent < 10 Then
ReportFile.WriteLine "<tr><td align=left>" & Drv & "</td><td align=left>" & VolName & "</td><td align=center>" & TotSpace & "</td><td
align=center>" & UsSpace & "</td><td align=center>" & FrSpace & "</td><td bgcolor='#FF0000' align=center>" & FrPercent & "%" &"</td></tr>"
Else
ReportFile.WriteLine "<tr><td align=left>" & Drv & "</td><td align=left>" & VolName & "</td><td align=center>" & TotSpace & "</td><td
align=center>" & UsSpace & "</td><td align=center>" & FrSpace & "</td><td bgcolor='#FBB917' align=center>" & FrPercent & "%" &"</td></tr>"
End If
Else
End If
Next
ReportFile.writeline("<tr>")
ReportFile.writeline("<td width='100%' colSpan=6> </td>")
ReportFile.writeline("</tr>")
ReportFile.writeline("</tbody></table>")
'Incrementing the Server List line value and running the routine
'i = i + 1
Loop
ReportFile.WriteLine "</body></html>"
ReportFile.Close
SendAlert=TRUE
VarTo = "irshad@sc.com"
If SendAlert then
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "diskspace report" & date() & " " & time()
objMessage.From = "irshad@cbd.com"
objMessage.To = VarTo
' objMessage.TextBody = "Alert - Excessive user mailbox growth"
objMessage.CreateMHTMLBody "file://c:\temp\diskspace.htm"
'objMessage.CreateMHTMLBody "file://c:\temp\OneMail\monitorDumpster\CS_Mailbox_Sizes.html"
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "172.11.14.22"
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
objMessage.Send
set objMessage=Nothing
If ERR.Number<>0 then
WScript.Echo "ERR: Sending mail"
ERR.Clear
End If
end if
Thanks.
Hello everybody
I am unable run following script using the current browsers.
please help
<scriptlanguage="vbscript"type="text/vbscript"> var1 =10 var2 =20Sum= var1 + var2 document.write("The Sum of two numbers"&_"var1 and var2 is "&Sum)</script>
the document object is giving no results.
Hello.
I'm developing a script to connect to the registry of a remote computer, as the excerpt below.
param ([String]$computer) $sKeyA = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" $type = [Microsoft.Win32.RegistryHive]::LocalMachine $oReg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($type, $computer)
But, the computers here at the company have a hyphen in the name (ex: 100-0223) and when I run the script passing computer parameter it shows the following error message:
Exception calling "OpenRemoteBaseKey" with "2" argument(s): "The network path was not found."
If I run the same command on the computer that I want (locally on the target computer), the script works
I did a test using a computer without a hyphen in the name and it worked.Rodrigo de Oliveira
Hi,
I am lookingto put anewpossibility, theNICbind orderwithPowerShell.
The use of nvspbind isunfortunatelynot an option.
$ServerName = "work" $objReg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $ServerName) $objRegKey = $objReg.OpenSubKey("SYSTEM\\Currentcontrolset\\Services\\TCPIP\\Linkage" ) $arrItem = $objRegKey.GetValue("Bind") $arrItem
Seeking an opportunity to re-sort the outputof $arrItemand the RegKeythen rewrite.
Does anyone have an
idea?
I need to check what SQL Server services are running(engine,agent,IS,AS,RS,browser and Full text) and what is the present status and what service accounts are been used by them on several servers in a single shot.
Could any one help me in finding a good script for the same.
I want to write a batch file which search for .exe from two folder in the network and override the old one with the new .
As iam new to batch programming i would like have code in details if any one help me i will very much thankful
Thanks in Advance.
I have about 30k image files on my pc in 1 dir C:\TEMP1\ for example. These files all have to be renamed to a specific unique name. Aside from these files I also have an xml file that contains properties for these files, document title, document id for example. The xml file also contains the path and file name of the image files. I need a script that can read the xml file, find the tag <ExternalRef> and then go out to C:\TEMP1\ and rename that file according to other xml tags such as document title and document id. I have 1 xml file for all 30k images. I dont have any scripting experience and was looking for some help.
This is what the xml file looks like: So I need to find <ExternalRef>file://C:\TEMP1\000E57BC.TIF</ExternalRef> and rename that file to <DocumentTitle>Probate Order-SO</DocumentTitle> _<ABC_DocumentID>APO24L977</ABC_DocumentID>...etc
- <ABC_TitleDocument>
- <ABC_TitleDocumentProperties>
<ObjectType>1</ObjectType>
<Creator>Administrator</Creator>
<DateCreated>2013-10-07T16:45:27.237Z</DateCreated>
<LastModifier>Administrator</LastModifier>
<DateLastModified>2013-10-07T16:45:27.237Z</DateLastModified>
<Id>6132c424-007b-4ef9-9c07-2b8171b83357</Id>
<Name>Probate Order-SO</Name>
<SecurityPolicy />
<SecurityParent />
<IsFrozenVersion>0</IsFrozenVersion>
- <VersionSeries>
- <ObjectRef>
<ObjectId>1be7c26c-89d2-40bf-afeb-a081714e470a7</ObjectId>
<ClassId>01a3a8c8-7aec-11d1-a31b-a0020af9fbb1c</ClassId>
</ObjectRef>
</VersionSeries>
<MajorVersionNumber>1</MajorVersionNumber>
<MinorVersionNumber>0</MinorVersionNumber>
<VersionStatus>1</VersionStatus>
- <ContentElements>
- <ContentTransfer>
<ObjectType>1038</ObjectType>
<ContentType>image/tiff</ContentType>
<RetrievalName>000E57ABC.TIF</RetrievalName>
<ExternalRef>file://C:\TEMP1\000E57BC.TIF</ExternalRef>
</ContentTransfer>
</ContentElements>
<MimeType>image/tiff</MimeType>
<DocumentLifecyclePolicy />
<DocumentTitle>Probate Order-SO</DocumentTitle>
<SourceDocument />
<OwnerDocument />
<PublicationInfo />
<IgnoreRedirect />
<EntryTemplateObjectStoreName />
<EntryTemplateLaunchedWorkflowNumber />
<EntryTemplateId />
<ABC_Area>P</ABC_Area>
<ABC_DocumentCategory>Title</ABC_DocumentCategory>
<ABC_DocumentClass>11</ABC_DocumentClass>
<ABC_DocumentID>APO24L977</ABC_DocumentID>
<ABC_LandArea>151</ABC_LandArea>
<ABC_ScanDate>2013-10-07T05:00:00Z</ABC_ScanDate>
<ABC_ScanOperator>Administrator</ABC_ScanOperator>
<ABC_ScanWorkstationID>SCN04:Sess 3</ABC_ScanWorkstationID>
<ABC_Agency>03</ABC_Agency>
<ABC_DocumentType>ABC</ABC_DocumentType>
<ABC_LTRO>P</ABC_LTRO>
<ABC_KofaxID>{DA701CAD-5CB2-444e-9ABBB-47CF0B2FD801}</ABC_KofaxID>
<ABC_DocumentCount>11</ABC_DocumentCount>
<ABC_Recordable>1</ABC_Recordable>
<ABC_BatchType>FOLLOW-UP</ABC_BatchType>
<ABC_EStamped>0</ABC_EStamped>
<ABC_RecordationState>PENDING</ABC_RecordationState>
<ABC_FileName />
<ABC_FolderName />
<ABC_BatchName>10/7/2013 8:25:26 AM</ABC_BatchName>
<ABC_RecordDate>11/19/2004</ABC_RecordDate>
<ABC_DocumentDate>1977-03-30T05:00:00Z</ABC_DocumentDate>
<ABC_ConveyanceType>SO</ABC_ConveyanceType>
</ABC_TitleDocumentProperties>
</ABC_TitleDocument>