Windows上类似挖功能?

时间:2019-01-14 04:53:40

标签: windows powershell perforce dig

在Windows系统上,我正在尝试收集DNS名称的所有IP地址,并使用每个IP地址调用工具。我知道如何从Shell脚本执行操作-但不知道如何从批处理或Powershell文件执行操作。

我想将此移植到Windows。

import { PermissionsAndroid } from 'react-native';

async function getLocation() {
  try {
    const granted = await PermissionsAndroid.request(
      PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
      {
        'title': 'App',
        'message': 'are you sure you want to share your location with the app ?'
      }
    )
    if (granted === PermissionsAndroid.RESULTS.GRANTED) {
      // permission granted
      // do code get location here.
      navigator.geolocation.getCurrentPosition(
        (pos) => {
          console.log(pos.coords.longitude, pos.coords.latitude);
        })
    } else {
      // permission denied
      console.log("GPS permission denied")
    }
  } catch (err) {
    console.warn(err)
  }
}

问题:

  1. 是否有等效的预安装Windows #!/usr/bin/env bash # Get all the IPs for our server instance # and pass it to "p4 trust" to update the .p4trust file for address in $(dig perforce.example.com +short) do echo "processing address: $address:1666" p4 -p "ssl:$address:1666" trust -y -f || true done 仅返回DNS记录的IP?
  2. 在批处理或Powershell文件中,如何遍历另一个应用程序的多个结果?

1 个答案:

答案 0 :(得分:2)

尝试一下...

Get-Command -Name Resolve-Dns* | Format-Table -AutoSize

CommandType Name                   Version Source       
----------- ----                   ------- ------       
Cmdlet      Resolve-DnsName        1.0.0.0 DnsClient     

# Get parameters, examples, full and Online help for a cmdlet or function

(Get-Command -Name Resolve-DnsName).Parameters
Get-help -Name Resolve-DnsName -Examples
Get-help -Name Resolve-DnsName -Full
Get-help -Name Resolve-DnsName -Online


# Get all IPAddresses for the provided DNS name
$env:USERDNSDOMAIN | ForEach{Resolve-DnsName -Name $_}

Name          Type   TTL   Section    IPAddress                                
----          ----   ---   -------    ---------                                
CONTOSO.COM A      600   Answer     192.168....                             
CONTOSO.COM A      600   Answer     10.10... 

# 
$env:USERDNSDOMAIN | 
ForEach{
    # Get all IPAddresses for the provided DNS name
    $DNSIPA = (Resolve-DnsName -Name $_).IPAddress

    # Check if the host is up for a given IPA and port number
    ForEach($IPA in $DNSIPA)
    {
        "Processing $IPA"
        Test-NetConnection -ComputerName $IPA -Port 1666
    }
}

但是,此问题将转化为您是PowerShell的新手。因此,在导致不必要的混乱/挫败感等之前,至关重要的是,您必须花时间使用所有可用的免费PowerShell视频和电子书培训资源来加快速度。这里只是几个。

MSDNMSDocsMVAMSChannel9YouTubeeBooks,请使用如上所述的帮助文件。