Sys_man

u/Sys_man


r/Ubiquiti•

I feel a bit stupid asking this question, because I'm sure the answer is simple, but it's been a fair while since I did more than the absolute basics of networking.

I have an edgemax router with:

eth0 = 10.0.0.10 connected to 10.0.0.1 on another router which is connected to the internet.

From the router's pov the eth0 connection is all good, pings internet fine.

eth1 = 192.168.1.1 connected to a pc, and that side of the network is fine. (from pc I can ping 192.168.1.1, and 10.0.0.10, but not 10.0.0.1)

The edgemax gateway is 10.0.0.1, so it has made a 0.0.0.0/0 next hop 10.0.0.1 route.

I'm trying to get the router to route 192 -> 10 and back but with no luck.

I'm not

33

r/PowerShell•

In the terminal if I do the following:

enter-pssession $server -credential $creds
$folderList = get-childitem "C:\Users" -directory | select name

I get a list of folders in "C:\Users" on the remote machine

However if I put the above in a script, $folderList contains a list of folders on the local machine.

So it seems enter-pssession doesn't work in a script. How does one go about doing the above in a script?

72


r/PowerShell•

I'm parsing a CSV file and need to grab a 5 character length number from within a string.

The string is like: Text 11010-00635 more text/other stuff

I need to get the second block of 5 digits (00635). [0-9]{5}\b unfortunately matches both. (11010 and 00635).

[0-9]{5}\s matches the second one but also gets the white space which is annoying. I can trim or replace to get rid of it but I was hoping for a more elegant solution.

I feel like the answer is simple but in my defence I've only had 3 coffees today, I'm barely awake.

119

r/vba•

I have a form that will be used to update a table based on user input. I want to do things right so am trying to parameterise my query, though I could build a simple string insert statement.

I can do it in powershell and ruby just fine, but vba is doing my head in.

The wrong way that I'd like to turn in to the right way:

Set rs = CreateObject("ADODB.Recordset")
Server_Name = "serverIP"
Database_Name = "db"
User_ID = "user"
Password = "pass"
Set Cn = CreateObject("ADODB.Connection")
Cn.Open "Driver={MySQL ODBC 5.1 Driver};Server=" & Server_Name & ";Database=" & Database_Name & _
    ";Uid=" & User_ID & ";Pwd=" & Password & "
23


r/PowerShell•

There's a public api, here, which is for retrieving information about schools in NZ.

I'm having trouble filtering the results. If I run the following I get a list limited to 5:

$uri = "https://catalogue.data.govt.nz/api/3/action/datastore_search?resource_id=bdfe0e4c-1554-4701-a8fe-ba1c8e0cc2ce&limit=5"

$test = Invoke-RestMethod -Uri $uri -Method Get

$test.result.records

And that's fine and all, but I want to query for a specific record, based on 'School_id'

(see fields [here](https://catalogue.data.govt.nz/dataset/directory-of-educational-institutions/resource/bdfe0e4c-15

614

r/mysql•

I'm querying a log table (that logs excel macro uses) which contains data like the following: macro_name | user_name | branch | update_time

I'm trying to return a list of all the distinct macro_names that a branch has run, and only select the newest update_time of each macro_name

Getting a list of all macros a branch has run is simple:

select  * from macro_log_table
where branch = <branch>

But I get results like this:

macro_1 | user1 | <branch> | 2020-01-06 09:19:08
macro_1 | user2 | <branch> | 2020-02-16 09:19:08
macro_1 | user3 | <branch> | 2020-01-26 09:19:08
macro_2 | user1 | <branch> | 2020-03-01 09:19:08
macro_2
16

r/sysadmin•

I have a folder of pdfs & xlsx's named <customer number>-Processed.(pdf/xlsx)

Meaning there is one pdf and one xlsx for each customer number.

The folder is an SMB share on a linux box

This error popped up when running a VBA macro, but is reproducible in powershell: for one particular entity, customer number '785', one file of another customer number is returned as well when you run get-childitem -filter 785*

ie:

get-childitem -filter 785*

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----      11/03/2020  9:17 a.m.          18393 777-Processed.xlsx
-a----      14/02/2020  2:35 p.m.    
34

r/ruby•

Hi there, I'm just trying to automate a process. We use a command line tool which is navigated by keystrokes (no mouse).

I was hoping to create a ruby script to send the required keystrokes to that tool, and am asking for your help on how to do that basic thing.

It's easy enough to start the program; system 'programName', but after that the script is hung until you exit the program.

I suspect the answer is something like 'create a new thread and send the keys' but I'm not sure how to do that.

thanks for any help you can provide

73

r/sysadmin•

I have a group of users who quite often need to print multiple photos on 1 a4 page. On previous versions of windows, Windows Photo Viewer would pop up when you 'right click -> print' on files. If you have multiple files selected and selected '4 per page' in the print options, the images would be nicely laid out on 1 page, taking a quarter each.

This is missing in windows 10, and more relevantly to my situation: server 2016 (RDP session hosts).

I am aware of some registry jiggery-pokery to get it back, but that seems like a '1 update away from breaking' solution.

Are there any easy to use (stress on the easy to use part), simple programs that would replicate the same functionality?

35


r/PowerShell•

I'm having a problem setting my execution policy in the integrated terminal in VSCode.

When I start up VSCode the integrated console has the following setting:

Get-ExecutionPolicy -list

Scope                ExecutionPolicy
-----                ---------------
MachinePolicy        Undefined
UserPolicy           Undefined
Process              RemoteSigned
CurrentUser          Bypass
LocalMachine         Bypass

I can run the following: set-executionpolicy bypass -scope process just fine, and for that session all is well.

Once I restart VSCode however, things revert back to 'RemoteSigned'

I do have the following setting in my settings.json: `"termin

92

r/PowerShell•

[long explanation incoming. question at the end]

I'm messing around with a module - PSTerminalServices, and am trying to format the output of a command; get-tssession. The default output looks like the following:

Server          SessionID State           IPAddress       ClientName      WindowStationName UserName            
------          --------- -----           ---------       ----------      ----------------- --------            

I'm trying to cut that table down to just:

Server          State       ClientName UserName            
------          -----       ---------- --------            

And I can see in the output of get-tssession | get-member that each of

47