» Publishers, Monetize your RSS feeds with FeedShow: More infos (Show/Hide Ads)
Hi all,
I have created a powershell script wich reads a variable from an INI file. I now have to convert this script to VB.
Get-Content "C:\Temp\pwruser.ini" | foreach-object -begin {$h=@{}} -process { $k = [regex]::split($_,'=');
if
(($k[0].CompareTo("") -ne 0) -and ($k[0].StartsWith("[") -ne $True)) { $h.Add($k[0], $k[1]) } }
$Printer
= $h.Get_Item("Printer")
----
I have to read a value within PWRUSER.ini starting with Printer=.
Hope someone can help me out with this one!
Thanks in advance!
Dynares Groep B.V.
Hi,
We have couple of issues observed with some applications these days. The services corresponding to the applications are in hung state (not responding) and this is causing an issue. From the services console the service looks to be in started state but is not accepting any new connections. The end user is flashed with error messages.
To identify this proactively, we would like to set up a monitor for this service which could send us an alert when the service is getting hung. This will assist us in taking the actions before we are flooded with the end user tickets.
To provide more details on this :
Service Name : Abc.svc
Services Type : Windows Service
Port : The service uses a specefic TCP port. ex 554
We are looking for a script or a monitor, that would poll on this service at a specefied interval and gives us a alert if the service is in not resopnding state..
Nitin
Hi there,
I want to run a script on windows XP that basically check if a certain regKey has certain value.
If it doesn't, add the new value
This is what I did:
---start of script---
reg query "HKU\.DEFAULT\Control Panel\Desktop" /v Wallpaper | find "%systemroot%\Web\Wallpaper\test.jpg"
if %ERRORLEVEL% == 1 (
reg add "HKU\.DEFAULT\Control Panel\Desktop" /v Wallpaper /d %systemroot^%\Web\Wallpaper\test.jpg /f
)
---end of script---
the script never add the new key.
I've tested the command to add the new key (line 3), and it work ok.
And running reg query "HKU\.DEFAULT\Control Panel\Desktop" /v Wallpaper
did show the value as "%systemroot%\Web\Wallpaper\test.jpg".
But if I run the command on line 1:
reg query "HKU\.DEFAULT\Control Panel\Desktop" /v Wallpaper | find "%systemroot%\Web\Wallpaper\test.jpg"
it never finds it.
turns out the find command treats the "%sytemroot%" string as a PATH - C:\WINDOWS.
so the question is:
how do I use the command find to detect the string %systemroot% ?
I've looked through available web resources in an attempt to find this answer but am still at a loss. I am trying to add a slide to an existing powerpoint presentation while using visual basic but keep getting an error.
here is the code I'm currently using
Set objPPT = CreateObject("Powerpoint.Application")
' Make it visible.
objPPT.Visible = True
' Open existing presentation
Set objPresentation = objPPT.Presentations.Open("c:\powerpoint.ppt")
LastSlide = ObjPresentation.Slides.Count
NextSlide = LastSlide +1
'add a new slide
objSlide = objPresentation.Slides.Add(NextSlide, ppLayoutText)
' Add some text.
ObjPresentation.Slides(NextSlide).Shapes(2).TextFrame.TextRange.Text = "total count = " & LastSlide
' Clean up.
objPresentation.Save
objPresentation.Quit
I am getting an error
Line: 13
Char: 1
Error Slide.Add: Invalid enumeration value
Code 80070057
Source: Microsoft Office PowerPoint 2007
I have written some WMI code in C# that works on the vast majority of computers. One bit of code uses Win32_Group and the other uses Win32_ComputerSystem. One some computers the code fails with System.Runtime.InteropServices.COMException (0x80040154). From searching, it appears this error code means "Class not registered" which seems kind of odd since these are pretty basic objects in Windows. On one customer's computer in particular (Vista SP2) this code worked for a while and then suddenly stopped working. I'm not sure this is related by in her event log VSS gives the error shown below. How do I fix this? Why isn't it working?
public static string GetGroupNameFromSid(SecurityIdentifier sid) {
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Group")) {
foreach (ManagementBaseObject group in searcher.Get()) {
string sddl = group["SID"] as string;
if (sddl != null && sddl.ToLower().Trim() == sid.Value.ToLower().Trim()) {
return group["Name"] as string;
}
}
}
throw new ArgumentOutOfRangeException("sid", string.Format("Could not get the group name for sid: {0}", sid.Value));
}
private bool IsComputerInDomain() {
using (ManagementObject mo = new ManagementObject(string.Format("Win32_ComputerSystem.Name='{0}'", SystemInformation.ComputerName))) {
return (bool)(mo["PartOfDomain"]);
}
}
'ConvertStringSidToSid', '0x80070539', '
Operation:
OnIdentify event
Gathering Writer Data
Context:
Execution Context: Shadow Copy Optimization Writer
Writer Class Id: {4dc3bdd4-ab48-4d07-adb0-3bee2926fd7f}
Writer Name: Shadow Copy Optimization Writer
Writer Instance ID: {958f558a-1f33-4d84-92ac-8ddba3e263e9}'
--"A provider, Rsop Planning Mode Provider, has been registered in the WMI namespace, root\RSOP, but did not specify the HostingModel property. This provider will be run using the LocalSystem account. This account is privileged and the provider may cause a security violation if it does not correctly impersonate user requests. Ensure that provider has been reviewed for security behavior and update the HostingModel property of the provider registration to an account with the least privileges possible for the required functionality."
--Same entries, only for "
I have spent the morning working a Powershell script that does exactly what I need. The problem is that I need the script to be run as a logon script within GPO, and since GPO only uses PS on Windows 7 or 2008, that won't work for a lot of our users.
Is there a way I can convert this back to a VBS file??
$stamp = Get-Date -Format "MM-dd-yy"
$timestamp = get-Date -format "h:mm:ss tt"
$computer = gc env:computername
$userName = gc env:username
$path = '\\comboivh02.ics.idaho.gov\Sysadmin$\UserLogonTrack'
$logType = switch($args){
1 {"Logged on"}
2 {"Logged off"}
}
$LogInfo = $stamp + " at " + $timestamp + " - " + $userName + " on " +$computer + " - " + $logType
$fileExists = Test-Path $path
if (!$fileExists){
$file = New-Item -ItemType file $path\'LogonLogoffLog.txt'
}
if($fileExists){
Add-Content $path\'LogonLogoffLog.txt' -Value $LogInfo
}i found useful script on: http://www.messageops.com/blog/index.php?url=archives/18-Microsoft-Exchange-Online-Mailbox-Backup-and-Restore.html&serendipity[csuccess]=moderate to export mailboxes from microsoft exchange online to local binary files. it goes like that:
Get-XsHostedExchangeMailboxdata -sourceserver "red001.mail.microsoftonline.com" -sourcelocation "https://red001.mail.microsoftonline.com/exchange" -sourceidentity exonlineTest@messageopsdemo.com | export-transporterbinary -targetfilepath c:\export -targetfileprefix "exonlinetest"
this makes a logon window pops up, and then it runs.
it worked fine for me and i like to script it for scheduled backup. how can i do it?
Hi,
I found this script in the Repository: List Servers in an Active Directory Site
When I run the script, it only lists the domain controllers in each site. I need a list of all the servers in specific AD Site. Help please....
Regards,
Krish P

Hi Everyone,
I am trying to load a flat file to a SQL server table. But before I load the file I need to manipulate the data as below (such that the user becomes a part of every row and for the values in the 4th column are transposed to form rows -
INPUT -
BBSA000 , DENNIS MACKENZIE
BBSA000 , ,MEMA , YNY , EMP ,12121
BBSA000 , ,MEMB , YYYY, EMP ,12121
BBSA000 , ,MEMC , YYYY, EMP ,12121
BBSA002 , GEORGE ROWLAND
BBSA002 , ,MEMA , YYYY, EMP ,12122
BBSA002 , ,MEMB , YNNY, EMP ,12122
OUTPUT -
BBSA000 , DENNIS MACKENZIE ,MEMA,Y,EMP,12121
BBSA000 , DENNIS MACKENZIE ,MEMA,N,EMP,12121
BBSA000 , DENNIS MACKENZIE ,MEMA,Y,EMP,12121
BBSA000 , DENNIS MACKENZIE ,MEMA, ,EMP,12121
BBSA000 , DENNIS MACKENZIE ,MEMB,Y,EMP,12121
BBSA000 , DENNIS MACKENZIE ,MEMB,Y,EMP,12121
BBSA000 , DENNIS MACKENZIE ,MEMB,Y,EMP,12121
BBSA000 , DENNIS MACKENZIE ,MEMB,Y,EMP,12121
BBSA000 , DENNIS MACKENZIE ,MEMC,Y,EMP,12121
BBSA000 , DENNIS MACKENZIE ,MEMC,Y,EMP,12121
BBSA000 , DENNIS MACKENZIE ,MEMC,Y,EMP,12121
BBSA000 , DENNIS MACKENZIE ,MEMC,Y,EMP,12121
(output split for clarity)
BBSA002 , GEORGE ROWLAND ,MEMA,Y,EMP,12122
BBSA002 , GEORGE ROWLAND ,MEMA,Y,EMP,12122
BBSA002 , GEORGE ROWLAND ,MEMA,Y,EMP,12122
BBSA002 , GEORGE ROWLAND ,MEMA,Y,EMP,12122
BBSA002 , GEORGE ROWLAND ,MEMB,Y,EMP,12122
BBSA002 , GEORGE ROWLAND ,MEMB,N,EMP,12122
BBSA002 , GEORGE ROWLAND ,MEMB,N,EMP,12122
BBSA002 , GEORGE ROWLAND ,MEMB,Y,EMP,12122
Can some one please suggest a data manipulation strategy/ script etc
Thanks in advance!
Regards,
Adam
I am trying to log when our users log on and off, and from what computer.
I have the following script so far:
$stamp = Get-Date -Format "MM-dd-yy"
$timestamp = get-Date -format "H:m:s"
$computer = gc env:computername
$userName = gc env:username
$LogInfo = $stamp + " at " + $timestamp + " - " + $userName + " on " +$computer + " - Logged on"
$path = '\\comboivh02.ics.idaho.gov\Sysadmin$\UserLogonTrack'
$fileExists = Test-Path $path
if (!$fileExists){
$file = New-Item -ItemType file $path\'LogonLog.txt'
}
if($fileExists){
Add-Content $path\'LogonLog.txt' -Value $LogInfo
}
But I would like to determine if someone is already logged on, so I can send them to other code functions and mark them as logged off when they log off their computers......
Also, when I'm trying to capture the login name by using: $userName = gc env:username its giving me strange results....the last person who logged in, the log recorded his name as com-computername$, instead of his name.... we use com- and the users name, so it recorded that instead of his AD username.
Why?
I need to write a script (WinXP Pro SP3) that will check the date every time my PC powers up, and if it is a certain date of the year, a message window (or something similar and simple) will display reminding me of an annual task to be performed once each year. It is not a PC-related task so all I need is the annual reminder. I tried to find a way using Outlook to do this but nothing is available that will do this without me actually running Outlook every day, which defeats the purpose; I want something I can install to run in the background and forget about it except once every year. I could also easily write, say, a VB program (I am a retired data programmer) to run at startup, but that seems like using an elephant to swat a fly.
If you think a script is not the best way to do this, please feel free to lead me elsewhere.
Thanks
Pete B
Hi,
I have to record all settings of our GPO for revision, even the keys, which are not defined. When I save a GPO-Report in HTML via GMPC I've only the key which are defined. Is there a way to get a report of all values of a GPO? All the normal tools (GPMC etc) only show the values which are not "not defined". But I need the "complete GPO" with all values.
Thanks!
Hi,
Can someone please helpme with a script that will enable to me to count the total number of files present in all drives on a number of servers.
Hi,
Am working on a script to run a program from a network drive be I only want a limited amount of users to access it, most of it is completed there is just the matter of closing the network drive once the program is closed this is so other users can access it.
When I close the program I would like something to keep checking to see if it is running, then when the program is closed the last part of the script will disconnect the network drive.
Here is the code that I have been playing with;
sAppName = "Program Name"
sAppPgm = "Program.exe"
'ON ERROR RESUME NEXT
WSHNetwork.MapNetworkDrive "I:", "\\appserv1\NetwrkApps",True
wscript.sleep 500
WSHShell.Run "I:\programname\bin\Program.exe"
Do Until WSHShell.AppActivate(sAppName) = False
Loop
WSHNetwork.RemoveNetworkDrive "I:"
How ever this just ignores the Loop and goes straight to the RemoveNetworkDrive.
Any points in the right direction would be great...
Many Thanks
Karl
Hi there,
I've created a computer startup script for
Windows XP : startup.bat and assigned it to computer startup on group policy.
What it does is it will create a new folder under c:\windows\_test and then copy a file from a network chare.
this is what I put it:
mkdir c:\windows\_test
copy \\server_IP\shared\info.txt c:\windows\_test\
the new folder was created ok but the file never copied.
I put in an extra command ...\_test\ > c:\copy.log and it only says "Access is denied".
On the shared folder, I've included domain computers to have full control and I also checked the [Effective Permission], the computer account does have the necessary permission.
what went wrong?
Additional information:
it works for Windows 7

I can't check delivery reports of messages via ECP. This is the error presented:
"The status for the recipient can't be determined because of a temporary error. Please try again later."
Any ideas?
TMK
Note: I would like to use Powershell for this as I am trying to learn my way around powershell.
I have a .ps1 file that has the following lines in it:
ftp '-s:C:\ATM\Scripts\GET_RCM_HOST.ftp'
Rename-Item C:\ATM\RCM\RCM.DAT RCM3043.DAT
ftp -s:c:\ATM\Scripts\PUT_RCM_Fiserv.ftp
Move-Item C:\ATM\RCM\RCM3043.DAT ("C:\ATM\ARCHIVE\RCM\RCM3043_{0:MMddyyyyhhmmss}.DAT" -f (get-date))
Here is what the first ftp script file looks like:open 192.168.XXX.XXX username password lcd /ROOT/RCM get RCM.DAT quit
This is fine as it does work, however, it won't exit the ftp command when I run this in a powershell window. I get the following:
ftp> quit 221 Goodbye. ftp>
After this I am forced to manually type in quit again for the script to continue running. The script finishes successfully after I manually type in the additional "quit" command.
Here are my questions:
- Why is it not leaving the ftp program on quit, if I do it manually it does it as intended?
- Is there a better way to be doing this?
- If so, please explain.
- Should I just give up on using powershell?
Levi
I am attempting to use powershell to delete files in subfolders older than 30 days without deleteing the subfolders
Here is the code I have pieced together most of it is from the web and I am just starting to learn powershell so please forgive my ignorance
I would also like it to log the files that are deleted and error handling for empty folders. Right know I am getting an error message on the $_.LastWriteTime
Error Messge>>>>>
Remove-Item $($_.FullName+"\*") -rec -force -WhatIf | Where <<<< ($_.LastWriteTime -lt (get-date).AddDay
+ CategoryInfo : InvalidArgument: (:) [Where-Object], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.WhereObjectCommand
Code >>>
get-Childitem C:\SCAN | Where{$_.PSIsContainer} | %{
[string[]]$processedFolders += $_.FullName
Remove-Item $($_.FullName+"\*") -rec -force -WhatIf | Where ($_.LastWriteTime -lt (get-date).AddDays(-30))
}
Is it possible to disconnect idle share sessions, I have noticed that network drives have a continuous session, if there are no open files then close the session.
Thanks for any help on this one.
Karl






