Script for getting the online/offline status
Hi all,
After enabling checkbox of "Enable assistive access device" is possible to get the online/ offline status.From Menu we will get the status.Without doing this i want to get the apple mail account online/offline status.hope some help scripts for this.
[That script|http://discussions.apple.com/message.jspa?messageID=11012484#11012484] could change the Online Status of all mail accounts. The following one will just report their Online Status. Is this what you are (were) asking for?
--BEGINNING OF SCRIPT
tell application "Mail" to activate
tell application "System Events" to tell process "Mail"
set theMenu to menu "Mailbox" of menu bar 1
if enabled of menu item "Take All Accounts Online" of theMenu then
return "All accounts are currently offline"
else
return "All accounts are currently online"
end if
end tell
--END OF SCRIPT
Similar Messages
-
Need VB script for getting the IIS certification information
Hi guys,
I have totally 1000 IIS servers 2003 & 2008
windows and some of the servers configured
IIS 3rd party Security certificates. I need a script to get the certification information like expiry date & certificate vendor name.
Regards,
SreeMPost here:http://forums.iis.net/
Look in Gallery for IIS scripts:http://gallery.technet.microsoft.com/
¯\_(ツ)_/¯ -
Script for: Getting the closest price within the group
Hello
I need some help for my script.I would like to add new field . Do you guys have an idea any OLAP functions .
It was my simple script which doesn't give the answer I want.
SELECT
NO,
SUM_QTY,
QTY_QUOTED,
CASE WHEN QTY_QUOTED < SUM_QTY
THEN MAX(QTY_QUOTED)
WHEN QTY_QUOTED = SUM_QTY
THEN QTY_QUOTED
WHEN QTY_QUOTED > SUM_QTY
THEN MIN(QTY_QUOTED) END AS CLOSEST_Q
from table1
GROUP BY NO, SUM_QTY, QTY_QUOTED;
output for the script below:
No SUM_QTY QTY_QUOTED CLOSEST_Q
567 3 2 2
567 3 99 99
130 140 156 156
123 515 40 40
911 120 600 600
911 120 800 800
567 3 3 3
567 3 5 5
911 120 700 700
130 140 138 138
130 140 12 12
123 515 2 2
I would like to see the last field below:
No Sum_Qty Qty_Quoted The Field I want to have or The other way I want to see
==== ======= ======== ================ ==================
123 515 40 x 40
123 515 2 40
567 3 5 3
567 3 2 3
567 3 3 x 3
567 3 99 3
911 120 600 x 600
911 120 700 600
911 120 800 600
130 140 12 138
130 140 138 x 138
130 140 256 138
I willl appreciate if you can give any clue /solution or idea.
Thanks a lot,
Pinar[That script|http://discussions.apple.com/message.jspa?messageID=11012484#11012484] could change the Online Status of all mail accounts. The following one will just report their Online Status. Is this what you are (were) asking for?
--BEGINNING OF SCRIPT
tell application "Mail" to activate
tell application "System Events" to tell process "Mail"
set theMenu to menu "Mailbox" of menu bar 1
if enabled of menu item "Take All Accounts Online" of theMenu then
return "All accounts are currently offline"
else
return "All accounts are currently online"
end if
end tell
--END OF SCRIPT -
Unix script for checking the user account status
Hi All,
i have created one unix script to check the status of the user in diff databases.
#!/bin/ksh
useracctreport.txt if [ ! -f hh ];
then
echo "Database file does not exist"
fi
echo "Enter Username"
read USER
echo "Enter the password"
stty -echo
read PASS
stty echo
for j in `cat users`
do
j="`echo $j| tr '[a-z]' '[A-Z]'`"
for i in `cat hh`
do
sqlplus -s $USER/$PASS\@$i <<EOF >> useracctreport.txt
column USERNAME format a8
column ACCOUNT_STATUS format a5
!echo "*****User $j Status in $i DB*****"
select USERNAME,ACCOUNT_STATUS from dba_users where username=('$j');
select OBJECT_TYPE,count(*) from dba_objects where owner='$j' group by object_type;
EOF
done
done
In log file ,i get the below error when its unable to connect to the DB.
SP2-0306: Invalid option.
Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}] | [INTERNAL]
where <logon> ::= <username>[<password>][@<connect_string>] | /
SP2-0306: Invalid option.
Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}] | [INTERNAL]
where <logon> ::= <username>[<password>][@<connect_string>] | /
SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
ERROR:
ORA-01017: invalid username/password; logon denied
Is there any way i can supress this error?
and is there any other way i can make this script faster.Thanks a lot for your helpHi,
The failing line is
sqlplus -s $USER/$PASS\@$i <<EOF >> useracctreport.txtYou should test the connect statement you provide to sqlplus. For example:
CONSTRING=$USER/$PASS\@$i
echo Connect string used: $CONSTRING
sqlplus -s $CONSTRING <<EOF >> useracctreport.txtCheck the echoed value. It's malformed. Correct it appropriately.
Yoann. -
Power Shell Script for getting the list of members of a particular collection group
Hi Group
I am looking for a powershell script for the below manual process in sccm2012. please help
Obtain the list of “All Users Group1” collection that have been defined as a Primary User of a device, and what that Users ShortName and Device name is
Obtain the list of user from Active Directory that have their “Title” attribute equal to “Non-Employee” (samAccountName)
For each user that is returned from AD, determine if they are assigned as a Primary User of a Device and write the Device name to a file
Continue to append all of the applicable Device names to the file
End Result = List of all Devices that have Users that have their AD Attribute “Title” equal to “Non-Employee”
thanks
VARHi,
The Cmdlets below should be helpful for you to write the script. You could have a look.
Get-CMUser
Get-CMUserDeviceAffinity
Get-ADUser
Best Regards,
Joyce Li
We
are trying to better understand customer views on social support experience, so your participation in this
interview project would be greatly appreciated if you have time.
Thanks for helping make community forums a great place. -
Getting apple mail account online/offline status through apple script
Please let me know,If anyone have idea of getting apple mail account online / offline status through apple script.
mohammed jasum k p wrote:
Otherwise how to get the online/offline status value.If u can please give me a solution for this.
this is not possible by any means I know. not every problem has a solution, sorry. -
Script for Checking the Server Status
Hi All,
I just need the script for monitoring the server status through the WLST.My scenario:I have 2 server in Running State.If any one of the server get failed or in not RUNNING state then i use the script for starting that server automatically.I tried some of the script but it is not working properly .If any one have the sample script please share with me.
Regards,
Ove.Hi Syed,
Replication state is very easy to see in 4.x and earlier. The last changenumber in the supplier changelog is visible (on the root DSE IIRC), and each consumer suffix has an operational attribute "copiedfrom" that tells you the name of the supplier, the database generation id, and the last change replayed from the supplier.
So a script that compares the results of
ldapsearch -h <supplier> -s base -b "" "objectclass=*" lastchangenumber
and
ldapsearch -h <consumer> -s base -b <base_suffix> "objectclass=*" copiedFrom
will show you if a replica has fallen out of sync. It won't tell you more than how many changes behind the replica is, though, because pre-5.x changenumbers are sequential integers, not timestamps.
However, the change that corresponds to the changenumber is clearly visible under the "cn=changelog" suffix. So if you look at the change itself you can see the timestamp on it.
For more info on the status of replication, you should be able to query the agreements on the supplier. Those live under the "Netscape Machine Data Suffix", which you can also find on the supplier's root DSE:
ldapsearch -h <supplier> -s base -b "" "objectclass=*" netscapemdsuffix
And of course the error logs will usually tell you if replication is failing outright.
I may be off on some of the attribute names, but if you do some investigating along these lines, you should be able to figure it out. -
Hi Experts,
I am trying to build a PowerShell Script to get the details Like Scope,Last Deployed date and Name for a Solution Deployed in the Farm.
Can anyone advise on this please.
RegardsGet-SPSolution|Select Name,Scope,LastOperationResult,LastOperationEndTime|Export-CSV "SPInstalledSolutions.csv" -NoTypeInformation
SPSolution properties
Get-SPSolution
This post is my own opinion and does not necessarily reflect the opinion or view of Slalom. -
Script for getting mail if database is down
Hi Friends,
OS Version : IBM AIX 5,2
Oracle version : 9.2.0.7
I am executing the following script for getting mail alert if database is down. some how the script is not working
check_stat=`ps -ef|grep ${ORACLE_SID}|grep pmon|wc -l`;
oracle_num=`expr $check_stat`
if [ $oracle_num -lt 1 ]
then
exit 0
fi
# Test to see if Oracle is accepting connections
$ORACLE_HOME/bin/sqlplus -s "/as sysdba" > /tmp/check_$ORACLE_SID.ora
select name from v$database;
exit
# If not, exit and e-mail . . .
check_stat=`cat /tmp/check_$ORACLE_SID.ora|grep -i error|wc -l`;
oracle_num=`expr $check_stat`
if [ $oracle_num -ne 0 ]
then
mailx -s "$ORACLE_SID is down!" [email protected] < /tmp/check_$ORACLE_SID.ora
exit 16
fi
I am saving this as .sh file and executing at command prompt. It is just hanging, but not throwing any error.
I would like to know if there is anything to be modified in the script or please provide me any such script. Thanks in advanceHI there.
I have a script I use that works really well. It sends out an email only if the database is down and also reads an ini file to process a blackout period and a priority level of the database... High priority databases are monitored every 5 minutes and Medium priority databases every hour.
There are two scripts, the shell script and the .ini file and I have two cron entries...
Check script:_
#!/bin/ksh
# check_oracle_status.sh
# Script to check if Oracle db's are up and running.
# Script is passed a priority field and reads check_oracle_status.ini
# to determine which db's to check. If db is down an email is sent.
# Priority Levels:
# H - Checks db's with "H"igh Priority every 5 minutes (cron)
# M - Checks db's with "M"edium Priority every hour (cron)
# L - db's with "L"ow Priority currently not checked
# Script Change History:
# ======================
# October 29th, 2009 - Initial Creation
# Set environment
export SCRIPTHOME=/opt/oracle/admin/scripts
export INIFILE=$SCRIPTHOME/check_oracle_status.ini
export PRIORITY=$1
. $HOME/.profile
db=`grep -i ":$PRIORITY" $INIFILE | cut -d":" -f1`
check_database()
sqlplus <<! > $SCRIPTHOME/check.out
/ as sysdba
select * from dba_data_files;
exit
grep ORA- $SCRIPTHOME/check.out > $SCRIPTHOME/error.out
if (( $? )); then
echo ""
else
mailx -s "Oracle instance $i is currently UNAVAILABLE" +<email address>+ < $SCRIPTHOME/error.out
fi
for i in $db ; do
fields=`grep $i $INIFILE | awk -F':' '{ total = total + NF }; END {print total}'`
export ORACLE_SID=$i
if [ $fields -gt 2 ]; then
BLACKOUT_START=`grep -i "$ORACLE_SID" $INIFILE | cut -d":" -f3`
BLACKOUT_END=`grep -i "$ORACLE_SID" $INIFILE | cut -d":" -f4`
CURRENT_HOUR=`date +%H`
CHECK_BASE=YES
if [ $BLACKOUT_START -gt $BLACKOUT_END ]; then
(( $CURRENT_HOUR >= $BLACKOUT_START || $CURRENT_HOUR <= $BLACKOUT_END )) && CHECK_BASE=
else
(( $CURRENT_HOUR >= $BLACKOUT_START && $CURRENT_HOUR <= $BLACKOUT_END )) && CHECK_BASE=
fi
if [ -n "$CHECK_BASE" ]; then
check_database
fi
else
check_database
fi
done
rm $SCRIPTHOME/check.out $SCRIPTHOME/error.out
INI File:_
oracle1:L
oracle2:M:17:08
oracle3:M
oracle5:M:17:08
oracle6:H
oracle7:M:17:08
oracle8:M
oracle9:M
Where oracle1,2,3 etc is your sid
L M and H your priority level
17 is blackout start (5 PM)
08 is blackout end (8 AM)
Note: Blackout is just a start hour and an end hour and must contain both or none and my script can only process one blackout per database. I guess if you
needed a second blackout you could add another line with different times for that sid
Cron entries:_
# Check Oracle Status
# The check_oracle_status.sh script monitors "H"igh priority databases every 5 minutes
# and "M"edium priority databases every hour
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /opt/oracle/admin/scripts/check_oracle_status.sh H > /dev/null 2>&1
0 * * * * /opt/oracle/admin/scripts/check_oracle_status.sh M > /dev/null 2>&1
Not sure if you require blackouts or priority levels but this setup works great at our site.
Hope this helps. -
Here are scripts for getting OAS302 working on RedHat 6.0
People have said this doesn't work. It works. It's just the
owsctl that doesn't work. I'm not saying that oas302 on RedHat 6
is the best solution anyone could come up with, but it does work,
and if you want to do it, here are some scripts that you can feel
free to modify and use as you wish. Various variables should be
updated with however you system is configured. Remember to start
the wrb (i.e. the second script) before you start any listeners.
Linux has a tendency to crash if you don't kill -KILL all the wrb
processes at the same time (i.e. the kernel gets an uncaught
exception and dies).
Erik
<disclaimer>
I do not guarantee these will work. I do not guarantee that
they will not destroy something important. I assume no liability
for what these scripts may or may not do. Use them at your own
risk. There is no expressed or implied waranty.
</disclaimer>
#!/bin/ksh
# Script to start the oraweb http servers to listen for requests
# because owsctl is kind of unpredictable under RedHat 6.0
# set this variable to be the directory that the webserver
# configuration drivetoryies are under (i.e.
# /db/app/oracle/admin/ows/web/httpd_my.host.com)
WEB_HOME=/db/app/oracle/admin/ows/web/httpd_my.host.com
LISTENER="$2"
if [[ -z "$LISTENER" ]]
then
echo "No listener name to start."
echo "Usage: listen {start|stop} listener"
echo "e.g.:"
echo " listen start admin"
exit 1
fi
case "$1" in
start)
OMN_ADDR=UDP:worf.gcg.com:2649
OWS_ADPCFG="$ORAWEB_HOME/admin/adpspy.cfg"
OWS_ADPSO="$ORAWEB_HOME/lib/ndwfs.so"
OWS_ORAWEB_FREEDOMX=1
export OWS_ADPCFG OWS_ADPSO OMN_ADDR OWS_ORAWEB_FEEDOMX
CFG_FILE=$WEB_HOME/$LISTENER/config/sv$LISTENER.cfg
if [[ -f "$CFG_FILE" ]]
then
oraweb -C $CFG_FILE
else
echo "Could not find config file for $LISTENER:"
echo " $CFG_FILE"
exit 1
fi
stop)
PID_FILE=$WEB_HOME/$LISTENER/config/sv$LISTENER.pid
if [[ -f $PID_FILE ]]
then
kill `cat $PID_FILE`
if [[ $? -ne 0 ]]
then
echo "Could not stop oraweb $LISTENER process."
exit 1
fi
else
echo "Could not find oraweb $LISTENER PID file:"
echo " $PID_FILE"
exit 1
fi
echo "Usage: listen {start|stop} listener"
echo "e.g.:"
echo " listen start admin"
exit 1
esac
#!/bin/ksh
# Script to start up the Oracle Web Request Broker (wrb)
# processes manually because owsctl doesn't work on RedHat
# Linux 6.0
TMP_FILE=/tmp/wrb.pids
case "$1" in
start)
SLEEP=3
if [[ -f "$TMP_FILE" ]]
then
echo "$TMP_FILE exits. Make sure the wrb is not
already"
echo "running, remove $TMP_FILE, and run this script
again."
exit 1
fi
if [[ -z "$ORAWEB_HOME" ]]
then
echo "ORAWEB_HOME is not set. This environment variable"
echo "should be set to the directory where the oracle was"
echo "lives, i.e. /app/oracle/product/8.0.5/ows/3.0"
exit 1
fi
OMN_ADDR=UDP:my.host.com:2649
OWS_ADPCFG="$ORAWEB_HOME/admin/adpspy.cfg"
OWS_ADPSO="$ORAWEB_HOME/lib/ndwfs.so"
OWS_ORAWEB_FEEDOMX=1 # I have no idea what this does; I read
# about it in a newsgroup. Supposedly
# it makes the oas run faster
export OWS_ADPCFG OWS_ADPSO OMN_ADDR OWS_ORAWEB_FREEDOMX
PATH=$ORAWEB_HOME/bin:$PATH
mnaddrsrv -D &
echo -n "$! " > $TMP_FILE
sleep $SLEEP
mnrpcnmsrv &
echo -n "$! " >> $TMP_FILE
mnorbsrv &
echo -n "$! " >> $TMP_FILE
sleep $SLEEP
wrbcfg &
echo -n "$! " >> $TMP_FILE
sleep $SLEEP
wrblog &
echo -n "$! " >> $TMP_FILE
sleep $SLEEP
wrbasrv &
echo -n "$! " >> $TMP_FILE
sleep $SLEEP
wrbahsrv &
echo -n "$! " >> $TMP_FILE
sleep $SLEEP
wrbroker &
echo -n "$! " >> $TMP_FILE
sleep $SLEEP
wrbvpm &
echo -n "$! " >> $TMP_FILE
sleep $SLEEP
wrbfac &
echo -n "$! " >> $TMP_FILE
sleep $SLEEP
wrbdm &
echo -n "$! " >> $TMP_FILE
sleep $SLEEP
stop)
kill -KILL `cat $TMP_FILE`
if [[ $? -ne 0 ]]
then
echo "Could not stop wrb processes. The PIDs are in"
echo "$TMP_FILE. If these are running, please"
echo "stop them manually."
else
rm -rf $TMP_FILE
fi
echo "Usage: wrb {start|stop}"
exit 1
esac
nullHi Erick,
Your scripts for running the OAS302 on 6.0 linux had been very
helpful.
In fact, I dont know what would I have done without them.
Now I am able to run the listeners and even able to create the
packages and users in the database via the OAS 3.0.2 but the
problem starts when accessing a procedure in the database using
the pl/sql agent. By the way i am using Oracle 8.0.5.1 RDBMS and
its home is different than the webserver home.
The browser just does nothing and even does not log any error
message ,I have to stop it after a while but all my other
catridges are working.
any insight will be appreciated.
thanks,
Vikram ( Ironically enough I work for Oracle).
Erik Nielsen (guest) wrote:
: People have said this doesn't work. It works. It's just the
: owsctl that doesn't work. I'm not saying that oas302 on RedHat
6
: is the best solution anyone could come up with, but it does
work,
: and if you want to do it, here are some scripts that you can
feel
: free to modify and use as you wish. Various variables should
be
: updated with however you system is configured. Remember to
start
: the wrb (i.e. the second script) before you start any
listeners.
: Linux has a tendency to crash if you don't kill -KILL all the
wrb
: processes at the same time (i.e. the kernel gets an uncaught
: exception and dies).
: Erik
: <disclaimer>
: I do not guarantee these will work. I do not guarantee that
: they will not destroy something important. I assume no
liability
: for what these scripts may or may not do. Use them at your own
: risk. There is no expressed or implied waranty.
: </disclaimer>
: #!/bin/ksh
: # Script to start the oraweb http servers to listen for
requests
: # because owsctl is kind of unpredictable under RedHat 6.0
: # set this variable to be the directory that the webserver
: # configuration drivetoryies are under (i.e.
: # /db/app/oracle/admin/ows/web/httpd_my.host.com)
: WEB_HOME=/db/app/oracle/admin/ows/web/httpd_my.host.com
: LISTENER="$2"
: if [[ -z "$LISTENER" ]]
: then
: echo "No listener name to start."
: echo "Usage: listen {start|stop} listener"
: echo "e.g.:"
: echo " listen start admin"
: exit 1
: fi
: case "$1" in
: start)
: OMN_ADDR=UDP:worf.gcg.com:2649
: OWS_ADPCFG="$ORAWEB_HOME/admin/adpspy.cfg"
: OWS_ADPSO="$ORAWEB_HOME/lib/ndwfs.so"
: OWS_ORAWEB_FREEDOMX=1
: export OWS_ADPCFG OWS_ADPSO OMN_ADDR OWS_ORAWEB_FEEDOMX
: CFG_FILE=$WEB_HOME/$LISTENER/config/sv$LISTENER.cfg
: if [[ -f "$CFG_FILE" ]]
: then
: oraweb -C $CFG_FILE
: else
: echo "Could not find config file for $LISTENER:"
: echo " $CFG_FILE"
: exit 1
: fi
: stop)
: PID_FILE=$WEB_HOME/$LISTENER/config/sv$LISTENER.pid
: if [[ -f $PID_FILE ]]
: then
: kill `cat $PID_FILE`
: if [[ $? -ne 0 ]]
: then
: echo "Could not stop oraweb $LISTENER process."
: exit 1
: fi
: else
: echo "Could not find oraweb $LISTENER PID file:"
: echo " $PID_FILE"
: exit 1
: fi
: echo "Usage: listen {start|stop} listener"
: echo "e.g.:"
: echo " listen start admin"
: exit 1
: esac
: #!/bin/ksh
: # Script to start up the Oracle Web Request Broker (wrb)
: # processes manually because owsctl doesn't work on RedHat
: # Linux 6.0
: TMP_FILE=/tmp/wrb.pids
: case "$1" in
: start)
: SLEEP=3
: if [[ -f "$TMP_FILE" ]]
: then
: echo "$TMP_FILE exits. Make sure the wrb is not
: already"
: echo "running, remove $TMP_FILE, and run this script
: again."
: exit 1
: fi
: if [[ -z "$ORAWEB_HOME" ]]
: then
: echo "ORAWEB_HOME is not set. This environment variable"
: echo "should be set to the directory where the oracle
was"
: echo "lives, i.e. /app/oracle/product/8.0.5/ows/3.0"
: exit 1
: fi
: OMN_ADDR=UDP:my.host.com:2649
: OWS_ADPCFG="$ORAWEB_HOME/admin/adpspy.cfg"
: OWS_ADPSO="$ORAWEB_HOME/lib/ndwfs.so"
: OWS_ORAWEB_FEEDOMX=1 # I have no idea what this does; I read
: # about it in a newsgroup. Supposedly
: # it makes the oas run faster
: export OWS_ADPCFG OWS_ADPSO OMN_ADDR OWS_ORAWEB_FREEDOMX
: PATH=$ORAWEB_HOME/bin:$PATH
: mnaddrsrv -D &
: echo -n "$! " > $TMP_FILE
: sleep $SLEEP
: mnrpcnmsrv &
: echo -n "$! " >> $TMP_FILE
: mnorbsrv &
: echo -n "$! " >> $TMP_FILE
: sleep $SLEEP
: wrbcfg &
: echo -n "$! " >> $TMP_FILE
: sleep $SLEEP
: wrblog &
: echo -n "$! " >> $TMP_FILE
: sleep $SLEEP
: wrbasrv &
: echo -n "$! " >> $TMP_FILE
: sleep $SLEEP
: wrbahsrv &
: echo -n "$! " >> $TMP_FILE
: sleep $SLEEP
: wrbroker &
: echo -n "$! " >> $TMP_FILE
: sleep $SLEEP
: wrbvpm &
: echo -n "$! " >> $TMP_FILE
: sleep $SLEEP
: wrbfac &
: echo -n "$! " >> $TMP_FILE
: sleep $SLEEP
: wrbdm &
: echo -n "$! " >> $TMP_FILE
: sleep $SLEEP
: stop)
: kill -KILL `cat $TMP_FILE`
: if [[ $? -ne 0 ]]
: then
: echo "Could not stop wrb processes. The PIDs are in"
: echo "$TMP_FILE. If these are running, please"
: echo "stop them manually."
: else
: rm -rf $TMP_FILE
: fi
: echo "Usage: wrb {start|stop}"
: exit 1
: esac
null -
Powershell script to get the low disk space on the servers...
Hi,
We have many SQL & Sharepoint servers running on windows server. I need some Powershell script to get the low disk space on those servers and it should send an mail alert saying "Disc d:\ have less than threshold 15% free space".
Awaiting for response.
Thanks
Anilyou should be able to use this powershell script which you can run as a scheduled task.
just change the details at the start of the script to point the script to the right location to create log files. you will need to have a plain text file containing a list of server names or ip addresses that you want to check drive space on.
# Change the following variables based on your environment
#specify the path to the file you want to generate containing drive space information
$html_file_dir = "\\server\share\DriveSpace"
#specify the path and file name of the text file containing the list of servers names you want to check drive space on - each server name on a seperate line in plain text file
$server_file = "\\server\share\servers.txt"
#speicfy the from address for the email
$from_address = "[email protected]"
#specify the to address for the email
$to_address = "[email protected]"
#specify the smtp server to use to send the email
$email_gateway = "smtp.domain.com" # Can either be DNS name or IP address to SMTP server
# The seventh line from the bottom (line 167) is used if your smtp gateway requires authentication. If you require smtp authentication
# you must uncomment it and set the following variables.
$smtp_user = ""
$smtp_pass = ""
# Change the following variables for the style of the report.
$background_color = "rgb(140,166,193)" # can be in rgb format (rgb(0,0,0)) or hex format (#FFFFFF)
$server_name_font = "Arial"
$server_name_font_size = "20px"
$server_name_bg_color = "rgb(77,108,145)" # can be in rgb format (rgb(0,0,0)) or hex format (#FFFFFF)
$heading_font = "Arial"
$heading_font_size = "14px"
$heading_name_bg_color = "rgb(95,130,169)" # can be in rgb format (rgb(0,0,0)) or hex format (#FFFFFF)
$data_font = "Arial"
$data_font_size = "11px"
# Colors for space
$very_low_space = "rgb(255,0,0)" # very low space equals anything in the MB
$low_space = "rgb(251,251,0)" # low space is less then or equal to 10 GB
$medium_space = "rgb(249,124,0)" # medium space is less then or equal to 100 GB
#### NO CHANGES SHOULD BE MADE BELOW UNLESS YOU KNOW WHAT YOU ARE DOING
# Define some variables
$ErrorActionPreference = "SilentlyContinue"
$date = Get-Date -UFormat "%Y%m%d"
$html_file = New-Item -ItemType File -Path "$html_file_dir\DiskSpace_$date.html" -Force
# Create the file
$html_file
# Function to be used to convert bytes to MB or GB or TB
Function ConvertBytes {
param($size)
If ($size -lt 1MB) {
$drive_size = $size / 1KB
$drive_size = [Math]::Round($drive_size, 2)
[string]$drive_size + ' KB'
}elseif ($size -lt 1GB){
$drive_size = $size / 1MB
$drive_size = [Math]::Round($drive_size, 2)
[string]$drive_size + ' MB'
}ElseIf ($size -lt 1TB){
$drive_size = $size / 1GB
$drive_size = [Math]::Round($drive_size, 2)
[string]$drive_size + ' GB'
}Else{
$drive_size = $size / 1TB
$drive_size = [Math]::Round($drive_size, 2)
[string]$drive_size + ' TB'
# Create the header and footer contents of the html page for output
$html_header = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Server Drive Space</title>
<style type="text/css">
.serverName { text-align:center; font-family:"' + $server_name_font + '"; font-size:' + $server_name_font_size + `
'; font-weight:bold; background-color: ' + $server_name_bg_color + '; border: 1px solid black; width: 150px; }
.headings { text-align:center; font-family:"' + $heading_font + '"; font-size:' + $heading_font_size + `
'; font-weight:bold; background-color: ' + $heading_name_bg_color + '; border: 1px solid black; width: 150px; }
.data { font-family:"' + $data_font + '"; font-size:' + $data_font_size + '; border: 1px solid black; width: 150px; }
#dataTable { border: 1px solid black; border-collapse:collapse; }
body { background-color: ' + $background_color + '; }
#legend { border: 1px solid black; ; right:500px; top:10px; }
</style>
<script language="JavaScript" type="text/javascript">
<!--
function zxcWWHS(){
if (document.all){
zxcCur=''hand'';
zxcWH=document.documentElement.clientHeight;
zxcWW=document.documentElement.clientWidth;
zxcWS=document.documentElement.scrollTop;
if (zxcWH==0){
zxcWS=document.body.scrollTop;
zxcWH=document.body.clientHeight;
zxcWW=document.body.clientWidth;
else if (document.getElementById){
zxcCur=''pointer'';
zxcWH=window.innerHeight-15;
zxcWW=window.innerWidth-15;
zxcWS=window.pageYOffset;
zxcWC=Math.round(zxcWW/2);
return [zxcWW,zxcWH,zxcWS];
window.onscroll=function(){
var img=document.getElementById(''legend'');
if (!document.all){ img.style.position=''fixed''; window.onscroll=null; return; }
if (!img.pos){ img.pos=img.offsetTop; }
img.style.top=(zxcWWHS()[2]+img.pos)+''px'';
//-->
</script>
</head>
<body>'
$html_footer = '</body>
</html>'
# Start to create the reports file
Add-Content $html_file $html_header
# Retrieve the contents of the server.txt file, this file should contain either the
# ip address or the host name of the machine on a single line. Loop through the file
# and get the drive information.
Get-Content $server_file |`
ForEach-Object {
# Get the hostname of the machine
$hostname = Get-WmiObject -Impersonation Impersonate -ComputerName $_ -Query "SELECT Name From Win32_ComputerSystem"
$name = $hostname.Name.ToUpper()
Add-Content $html_file ('<Table id="dataTable"><tr><td colspan="3" class="serverName">' + $name + '</td></tr>
<tr><td class="headings">Drive Letter</td><td class="headings">Total Size</td><td class="headings">Free Space</td></tr>')
# Get the drives of the server
$drives = Get-WmiObject Win32_LogicalDisk -Filter "drivetype=3" -ComputerName $_ -Impersonation Impersonate
# Now that I have all the drives, loop through and add to report
ForEach ($drive in $drives) {
$space_color = ""
$free_space = $drive.FreeSpace
$total_space = $drive.Size
$percentage_free = $free_space / $total_space
$percentage_free = $percentage_free * 100
If ($percentage_free -le 5) {
$space_color = $very_low_space
}elseif ($percentage_free -le 10) {
$space_color = $low_space
}elseif ($percentage_free -le 15) {
$space_color = $medium_space
Add-Content $html_file ('<tr><td class="data">' + $drive.deviceid + '</td><td class="data">' + (ConvertBytes $drive.size) + `
'</td><td class="data" bgcolor="' + $space_color + '">' + (ConvertBytes $drive.FreeSpace) + '</td></tr>')
# Close the table
Add-Content $html_file ('</table></br><div id="legend">
<Table><tr><td style="font-size:12px">Less then or equal to 5 % free space</td><td bgcolor="' + $very_low_space + '" width="10px"></td></tr>
<tr><td style="font-size:12px">Less then or equal to 10 % free space</td><td bgcolor="' + $low_space + '" width="10px"></td></tr>
<tr><td style="font-size:12px">Less then or equal to 15 % free space</td><td bgcolor="' + $medium_space + '" width="10px"></td></tr>
</table></div>')
# End the reports file
Add-Content $html_file $html_footer
# Email the file
$mail = New-Object System.Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($html_file)
$mail.From = $from_address
$mail.To.Add($to_address)
$mail.Subject = "Server Diskspace $date"
$mail.Body = "The diskspace report file is attached."
$mail.Attachments.Add($att)
$smtp = New-Object System.Net.Mail.SmtpClient($email_gateway)
#$smtp.Credentials = New-Object System.Net.NetworkCredential($smtp_user,$smtp_pass)
$smtp.Send($mail)
$att.Dispose()
# Delete the file
Remove-Item $html_file
Regards,
Denis Cooper
MCITP EA - MCT
Help keep the forums tidy, if this has helped please mark it as an answer
My Blog
LinkedIn: -
Need script for getting Uptime for remote servers
Hi Guys,
I'm in need of a script to get the UP time for windows servers in number of days. i have more than 1000 servers.
I dont want PowerShell script as i have many WIndows 2003 servers where PowerShell is not installed.
Please help me with this.
Thanks,
Kiran RajHi,
I'd look at the LastBootUpTime property that can be found by querying Win32_OperatingSystem.
Don't retire TechNet! -
(Don't give up yet - 12,700+ strong and growing) -
Scripts for changing the address of the user when they have been in the box for 6 months
Scripts for changing the address of the user when they have been in the box for 6 months
If users are in a folder for deactivated users and disabled users in Active Directory, and been there for 6 moths do: change email address in exchange to existing email address.old
Anyone have suggestions on how I can go about it?What is this "box"? What is this "folder" you're asking about? You'll likely get a better answer if you use standard terminology.
Ed Crowley MVP "There are seldom good technological solutions to behavioral problems." -
Script for getting all windows Drives freespace information
Hi All,
Any can post the batch script to get the disk drives freespace info for multiple servers.
Cheers,
GovindThis is not an Oracle Database question, so it really does not belong in this forum. You can query the WMI database in each server to find the information. Try the following search on Google:
hey scripting guy free disk spaceCharles Hooper
Co-author of "Expert Oracle Practices: Oracle Database Administration from the Oak Table"
http://hoopercharles.wordpress.com/
IT Manager/Oracle DBA
K&M Machine-Fabricating, Inc. -
Script for exporting the Delegated List from Exchange 2007
We are Planing to Migrate the Exchange 2007 Mailbox to O365 by Hybrid deployment.
So i would like to generate the List of delegated access rights on Mailboxes, could you help the script for genetating the delegated list.Hello,
Look into get-Help Get-MailboxPermission
Karl
When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
My Blog: Unlock PowerShell
My Book:
Windows PowerShell 2.0 Bible
My E-mail: -join ('6F6C646B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})
Maybe you are looking for
-
How can i call application ?
Can I call Application(exe) in a running vi ? I think i can do that using application vi platte but i don't know how to do ? can any one solve this problem ?
-
How to change "window LookAndFeel" of applet?
hi~~ I have changed the LookAndFeel of Applet with following code: try{ UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); SwingUtilities.updateComponentTreeUI(frame); catch(Exception e){} ,but WindowsLookAndFeel seem not
-
I got steam of error in Eventlog in windows 2008 in almost every second.
I had a iSCSI connection and removed the storage NIC card. I don't see anything in iSCSI Initiator Properties. There is no Target Portals or any discovered Target. I restarted iSCSI service, but it didn't help. Does anyone know the reason? Log Name:
-
Reorganizing SD/FI documents for credit management
Hello , we are in production already more than year but just now we will transport the settings of the credit managment. As there is many SD documents already do you advise me to execute any program to reorganize e
-
Publish for Approval with .Mac
If anyone has used the new "Publish for Approval" AppleScript and has found a way to publish these pages to a .Mac account/web page, would you tell me how you did it. I have been waiting for something like this forever but dont want to have to leave