08-29-2013
Help with PowerShell
I am very not knowledgeable with regards to Windows, and even more so with PowerShell, but I'm hoping someone can help me with what should be a fairly simple script.
Remove all local accounts matching a given regular expression
It seems like I'd need the following combined... Somehow...
Get-OSCLocalAccount | select-string .\*.* -pattern "^Name[\ \t]*: xxx.*$"
Which would get the account name lines, and then somehow iterate through those to delete accounts.... If it helps, this is the awk string / loop I'd need to account the same:
<Generate Output like Get-OSCLocalAccount> | awk -F: '/^Name[\t\ ]*: xxx/ {print $2}' | while read user; do userdel -r $user; done
Just been fumbling about with PowerShell and not having as much luck as I'd like. I know that I can user the net user del syntax to delete a user in Windows, but how to kick that off with PowerShell, how to loop from the previous output, etc. is giving me headaches. Hoping for either a hand or possibly a pointer to where else I should look. Ideally I won't ever have to do anything with PowerShell again (This should be a very extreme one-off) so I'm really not looking for a deep understanding of the language, just a working script here that I can add to a client's maint. schedule and be done with it.
Thanks for any/all help, it's much appreciated.
Last edited by Vryali; 08-29-2013 at 04:39 PM..
Reason: Typo
8 More Discussions You Might Find Interesting
1. Windows & DOS: Issues & Discussions
I.e. like vmstat, cpustat, iostat, fsstat, kstat ..etc? (1 Reply)
Discussion started by: Xcislav
1 Replies
2. Windows & DOS: Issues & Discussions
Need some help getting this script to work. can someone help. I am trying to create a script that moves log files to another location and only keeps 60 days worth. please see script I started but having issue getting to work..
$TODAY=GET-DATE
GET-CHILDITEM C:\test\*.LOG | Where {... (9 Replies)
Discussion started by: freedavis
9 Replies
3. Windows & DOS: Issues & Discussions
Hi All,
i have a VB script which help me in downloading the text file(mail attachment) to my local drive from outlook.i want to check some values in the text file. for ex
A
date1 count count miss
2/25/2014 42 42 0
B
date2 ... (0 Replies)
Discussion started by: mahesh300182
0 Replies
4. Windows & DOS: Issues & Discussions
Hello !
I am looking for powershell guys.
I have lot of office365 users ,and i need add/remove calendar items from powershell.
my users have multiple calendars.
how can i select calendar ,and how can i add / remove item to selected calendar.
PS C:\appl\o365calendar> get-mailboxfolder... (0 Replies)
Discussion started by: zoldkovacs
0 Replies
5. Shell Programming and Scripting
Hello Friend,
I am not expert in power shell scripting. I nee custom powershell script which check if given process is running on windows machine or not.
will use it in nagios to monitor that process. (0 Replies)
Discussion started by: ghpradeep
0 Replies
6. Shell Programming and Scripting
Hi
I have a powershell script which is checking whether a windows service is running (as shown below)
function FuncCheckService
{
$ServiceName = 'pgsql-9.2'
$arrService = Get-Service -Name $ServiceName
if ($arrService.Status -eq 'Running')
{
Write-Output... (8 Replies)
Discussion started by: simpsa27
8 Replies
7. UNIX for Beginners Questions & Answers
Hi Guys,
I am trying to run flyway command on ubuntu.
on windows command line is simple :
C:\Users\admin\Downloads\flyway-commandline-5.0.7-windows-x64\flyway-5.0.7> flyway migrate
how can i do it via bash?
i tied to use mnt command but starting flyway is not possible.
Please... (22 Replies)
Discussion started by: jaryszek
22 Replies
8. Windows & DOS: Issues & Discussions
Hi there,
How could I invoke powershell to:
1. Send a file or an attachment
2. Send a content to multiple recipient
3. Be invoked by a batch file to execute the param clause
Help will be appreciate.
param(
$highs, $mediums, $lows
)
$EmailFrom = “name@domain.com”
$EmailTo =... (0 Replies)
Discussion started by: alvinoo
0 Replies
LEARN ABOUT LINUX
pure-authd
pure-authd(8) Pure-FTPd pure-authd(8)
NAME
pure-authd - External authentication agent for Pure-FTPd.
SYNTAX
pure-authd [-p </path/to/pidfile>] [-u uid] [-g gid] [-B] <-s /path/to/socket> -r /program/to/run
DESCRIPTION
pure-authd is a daemon that forks an authentication program, waits for an authentication reply, and feed them to an application server.
pure-authd listens to a local Unix socket. A new connection to that socket should feed pure-authd the following structure :
account:xxx
password:xxx
localhost:xxx
localport:xxx
peer:xxx
end
(replace xxx with appropriate values) . localhost, localport and peer are numeric IP addresses and ports. peer is the IP address of the
remote client.
These arguments are passed to the authentication program, as environment variables :
AUTHD_ACCOUNT
AUTHD_PASSWORD
AUTHD_LOCAL_IP
AUTHD_LOCAL_PORT
AUTHD_REMOTE_IP
AUTHD_ENCRYPTED
The authentication program should take appropriate actions to fetch account info according to these arguments, and reply to the standard
output a structure like the following one :
auth_ok:1
uid:42
gid:21
dir:/home/j
end
auth_ok:xxx
If xxx is 0, the user was not found (the next authentication method passed to pure-ftpd will be tried) . If xxx is -1, the user was
found, but there was a fatal authentication error : user is root, password is wrong, account has expired, etc (next authentication
methods will not be tried) . If xxx is 1, the user was found and successfully authenticated.
uid:xxx
The system uid to be assigned to that user. Must be > 0.
gid:xxx
The primary system gid. Must be > 0.
dir:xxx
The absolute path to the home directory. Can contain /./ for a chroot jail.
slow_tilde_expansion:xxx (optional, default is 1)
When the command 'cd ~user' is issued, it's handy to go to that user's home directory, as expected in a shell environment. But
fetching account info can be an expensive operation for non-system accounts. If xxx is 0, 'cd ~user' will expand to the system user
home directory. If xxx is 1, 'cd ~user' won't expand. You should use 1 in most cases with external authentication, when your FTP
users don't match system users. You can also set xxx to 1 if you're using slow nss_* system authentication modules.
throttling_bandwidth_ul:xxx (optional)
The allocated bandwidth for uploads, in bytes per second.
throttling_bandwidth_dl:xxx (optional)
The allocated bandwidth for downloads, in bytes per second.
user_quota_size:xxx (optional)
The maximal total size for this account, in bytes.
user_quota_files:xxx (optional)
The maximal number of files for this account.
ratio_upload:xxx (optional)
radio_download:xxx (optional)
The user must match a ratio_upload:ratio_download ratio.
Only one authentication program is forked at a time. It must return quickly.
OPTIONS
-u <uid>
Have the daemon run with that uid.
-g <gid>
Have the daemon run with that gid.
-B Fork in background (daemonization).
-s </path/to/socket>
Set the full path to the local Unix socket.
-R </path/to/program>
Set the full path to the authentication program.
-h Output help information and exit.
EXAMPLES
To run this program the standard way type:
pure-authd -s /var/run/ftpd.sock -r /usr/bin/my-auth-program &
pure-ftpd -lextauth:/var/run/ftpd.sock &
/usr/bin/my-auth-program can be as simple as :
#! /bin/sh
echo 'auth_ok:1'
echo 'uid:42'
echo 'gid:21'
echo 'dir:/home/j'
echo 'end'
AUTHORS
Frank DENIS <j at pureftpd dot org>
SEE ALSO
ftp(1), pure-ftpd(8) pure-ftpwho(8) pure-mrtginfo(8) pure-uploadscript(8) pure-statsdecode(8) pure-pw(8) pure-quotacheck(8) pure-authd(8)
RFC 959, RFC 2389, RFC 2228 and RFC 2428.
Pure-FTPd team 1.0.36 pure-authd(8)